problem with the library libpci.a


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: problem with the library libpci.a

  1. #1
    Join Date
    Jun 2004
    Location
    France
    Posts
    5

    problem with the library libpci.a

    Hi,

    I'm having some trouble when I try to use the pci library. Indeed, I don't even succeed to make the exemple.c work. As I'm a beginner in programming let me tell you what I do (and maybe you'll find easily what is wrong).

    * I download the pciutils-2.1.11
    * I type "make" (it seems to work but if you want to take a look of what it does I wrote it at the end of this mail)
    * I type "make install" (I think it's not useful for what I want to do but anyway...)
    * then I go into the /lib directory and type :
    " g++ -o example example.c ./libpci.a
    and I get :

    /tmp/ccjwSteX.o(.text+0x11): dans la fonction « main »:
    : undefined reference to `pci_alloc()'
    /tmp/ccjwSteX.o(.text+0x1f): dans la fonction « main »:
    : undefined reference to `pci_init(pci_access*)'
    /tmp/ccjwSteX.o(.text+0x2d): dans la fonction « main »:
    : undefined reference to `pci_scan_bus(pci_access*)'
    /tmp/ccjwSteX.o(.text+0x4e): dans la fonction « main »:
    : undefined reference to `pci_fill_info(pci_dev*, int)'
    /tmp/ccjwSteX.o(.text+0x5e): dans la fonction « main »:
    : undefined reference to `pci_read_word(pci_dev*, int)'
    /tmp/ccjwSteX.o(.text+0xc3): dans la fonction « main »:
    : undefined reference to `pci_cleanup(pci_access*)'
    collect2: ld a retourné 1 code d'état d'exécution

    So if you have some time to answer me, it would be great.
    Thank you in advance.

    jean-yves

    ((would it be possible to write back at : jean_yves_m@hotmail.com ? thanks))


    when I type "make" :

    cd lib && ./configure /usr/local/share 2.1.11
    Configuring libpci for your system... Linux/i386 2.4.22-1.2149.nptl
    Looking for access methods... proc i386-ports dump
    make -C lib all
    make[1]: Entre dans le répertoire `/Download/pciutils-2.1.11/lib'
    cc -O2 -fomit-frame-pointer -Wall -W -Wno-parentheses -Wstrict-prototypes -c -o access.o access.c
    access.c: Dans la fonction « pci_null_debug »:
    access.c:119: attention : unused parameter `msg'
    cc -O2 -fomit-frame-pointer -Wall -W -Wno-parentheses -Wstrict-prototypes -c -o generic.o generic.c
    cc -O2 -fomit-frame-pointer -Wall -W -Wno-parentheses -Wstrict-prototypes -c -o dump.o dump.c
    dump.c: Dans la fonction « dump_cleanup »:
    dump.c:73: attention : unused parameter `a'
    dump.c: Dans la fonction « dump_scan »:
    dump.c:78: attention : unused parameter `a'
    dump.c: Dans la fonction « dump_write »:
    dump.c:100: attention : unused parameter `buf'
    cc -O2 -fomit-frame-pointer -Wall -W -Wno-parentheses -Wstrict-prototypes -c -o names.o names.c
    cc -O2 -fomit-frame-pointer -Wall -W -Wno-parentheses -Wstrict-prototypes -c -o filter.o filter.c
    filter.c: Dans la fonction « pci_filter_init »:
    filter.c:17: attention : unused parameter `a'
    cc -O2 -fomit-frame-pointer -Wall -W -Wno-parentheses -Wstrict-prototypes -c -o proc.o proc.c
    cc -O2 -fomit-frame-pointer -Wall -W -Wno-parentheses -Wstrict-prototypes -c -o i386-ports.o i386-ports.c
    i386-ports.c: Dans la fonction « conf12_cleanup »:
    i386-ports.c:39: attention : unused parameter `a'
    rm -f libpci.a
    ar rcs libpci.a access.o generic.o dump.o names.o filter.o proc.o i386-ports.o
    ranlib libpci.a
    make[1]: Quitte le répertoire `/Download/pciutils-2.1.11/lib'
    cc -O2 -fomit-frame-pointer -Wall -W -Wno-parentheses -Wstrict-prototypes -c -o lspci.o lspci.c
    cc -O2 -fomit-frame-pointer -Wall -W -Wno-parentheses -Wstrict-prototypes -c -o common.o common.c
    cc lspci.o common.o lib/libpci.a -o lspci
    cc -O2 -fomit-frame-pointer -Wall -W -Wno-parentheses -Wstrict-prototypes -c -o setpci.o setpci.c
    cc setpci.o common.o lib/libpci.a -o setpci
    M=`echo 2003-01-04 | sed 's/-01-/-January-/;s/-02-/-February-/;s/-03-/-March-/;s/-04-/-April-/;s/-05-/-May-/;s/-06-/-June-/;s/-07-/-July-/;s/-08-/-August-/;s/-09-/-September-/;s/-10-/-October-/;s/-11-/-November-/;s/-12-/-December-/;s/\(.*\)-\(.*\)-\(.*\)/\3 \2 \1/'` ; sed <lspci.man >lspci.8 "s/@TODAY@/$M/;s/@VERSION@/pciutils-2.1.11/;s#@SHAREDIR@#/usr/local/share#"
    M=`echo 2003-01-04 | sed 's/-01-/-January-/;s/-02-/-February-/;s/-03-/-March-/;s/-04-/-April-/;s/-05-/-May-/;s/-06-/-June-/;s/-07-/-July-/;s/-08-/-August-/;s/-09-/-September-/;s/-10-/-October-/;s/-11-/-November-/;s/-12-/-December-/;s/\(.*\)-\(.*\)-\(.*\)/\3 \2 \1/'` ; sed <setpci.man >setpci.8 "s/@TODAY@/$M/;s/@VERSION@/pciutils-2.1.11/;s#@SHAREDIR@#/usr/local/share#"
    sed <update-pciids.sh >update-pciids "s@^DEST=.*@DEST=/usr/local/share/pci.ids@"M=`echo 2003-01-04 | sed 's/-01-/-January-/;s/-02-/-February-/;s/-03-/-March-/;s/-04-/-April-/;s/-05-/-May-/;s/-06-/-June-/;s/-07-/-July-/;s/-08-/-August-/;s/-09-/-September-/;s/-10-/-October-/;s/-11-/-November-/;s/-12-/-December-/;s/\(.*\)-\(.*\)-\(.*\)/\3 \2 \1/'` ; sed <update-pciids.man >update-pciids.8 "s/@TODAY@/$M/;s/@VERSION@/pciutils-2.1.11/;s#@SHAREDIR@#/usr/local/share#"


    when I type "make install" :

    make -C lib all
    make[1]: Entre dans le répertoire `/Download/pciutils-2.1.11/lib'
    make[1]: Rien à faire pour `all'.
    make[1]: Quitte le répertoire `/Download/pciutils-2.1.11/lib'
    install -d -m 755 /usr/local/sbin /usr/local/share /usr/local/share/man/man8
    install -c -m 755 -s lspci setpci /usr/local/sbin
    install -c -m 755 update-pciids /usr/local/sbin
    install -c -m 644 pci.ids /usr/local/share
    install -c -m 644 lspci.8 setpci.8 update-pciids.8 /usr/local/share/man/man8

  2. #2
    Join Date
    Dec 2003
    Posts
    3,366
    the point of this forum is to have a record of q/a sessions to help many people, not a place to ask and hide the answer in private conversation. so do not ask for email response.

    It looks to me like you have a directory problem, so the program cannot resolve the functions from the .h file that are inside the .lib. However you do that in whatever version of make your machine thinks is correct, you will have to figure that one out.

  3. #3
    Join Date
    Jun 2004
    Location
    France
    Posts
    5
    Thanks jonnin.

    Do you have any idea of how solving a directory problem ? (Where should I put my files then ?)

    I was wondering, could it be also because I don't have some .h files which are needed ? (it's actually the case, for example I don't have some files such as : syscall-list.h)



    (by the way, I asked to answer at my Email @ because I'm not used to using forums and I didn't know I'd be warned when someone wrote back)

  4. #4
    Join Date
    Nov 2003
    Posts
    4,118
    when you register to these forums, you can specify whether you want the server to send you automatic email alerts when new posts are added to your thread, so there's no need to ask posters to reply to your email. Just a tip for all the members here;)

    As for the directories, you probably have to set them manually. The default directories which yoru IDE searches aren't the correct ones. I'm not familiar with this specific IDE but somewhere in the online help, you can find how to specify the linker's default libraries (and yes, these are linkage errors).
    Danny Kalev

  5. #5
    Join Date
    Jun 2004
    Location
    France
    Posts
    5

    I found the problem

    Well, I'm pretty ashamed to say that but I found the problem.

    libpci.a is a library which only works by being linked with gcc.
    So, the two important points in order to make it work are :
    - your file has to be a .c file (and not a .cpp)
    - you have to make the link with gcc.

    Example :
    gcc -c example.c
    gcc -o example example.o -lpci

    thanks Danny

  6. #6
    Join Date
    Jun 2004
    Location
    France
    Posts
    5
    ...or you can use :

    extern "C" {

    }

    .....

  7. #7
    Join Date
    Nov 2003
    Posts
    4,118
    absolutely!
    Danny Kalev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center