Newbie. Error with share library

From: el cintura partida (elcinturapartida_at_yahoo.es)
Date: 10/18/04


Date: 18 Oct 2004 13:27:08 -0700

Hello.

For some development I need write a application with source file
lspci.c and common.c from pciutils_2.1.11-1, all functions that I use
should be in my own shared library.

For example: The lspci.c and common.c files has the following
functions:

   pcifunc1()
   pcifunc2()
   pcifunc3()
   ...

Every function has a large number of options.

I have compiled it with

   gcc -fPIC -c lspci.c common.c

and creating Shared Libraries with:

$ gcc -shared -Wl,-soname,liblspci.so.1 lspci.o common.o -o \
          liblspci.so.1.1.1
$ su
Password:
# install -m 0755 liblspci.so.1.1.1 /usr/lib
# ldconfig
# ln -s /usr/lib/liblspci.so.1 /usr/lib/liblspci.so
# exit

For the first tests I have written a small program:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>

#include "pciutils-2.1.11-1/pciutils.h"
#include <pci/pci.h>

struct pci_dev *dev;
static struct pci_access *pacc;
static struct pci_filter filter;
int
main (void)
{
  pacc = pci_alloc ();
  pacc->error = die;
  pci_filter_init (pacc, &filter);
  pci_init (pacc);
  scan_devices ();
  sort_them ();
  show ();
  pci_cleanup (pacc);

  return 0;
}

when I compiled I got the following error message:

$ gcc -o example-lspci example-lspci.c -lpci -llspci
/tmp/ccEXisEt.o(.text+0x46): In function `main':
: undefined reference to `scan_devices'
/tmp/ccEXisEt.o(.text+0x4b): In function `main':
: undefined reference to `sort_them'
/tmp/ccEXisEt.o(.text+0x50): In function `main':
: undefined reference to `show'
collect2: ld returned 1 exit status
$

I am looking for a response to my problem in this newsgroup.

Thanks in advance.