Find the answer to your Linux question:
Results 1 to 2 of 2
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2004
    Posts
    1

    problem in using a 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.
    Thanks in advance.

    jean-yves

    ((would it be possible to write back directly 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
    Linux Guru
    Join Date
    Apr 2003
    Location
    London, UK
    Posts
    3,284

    Re: problem in using a library (libpci.a)

    Quote Originally Posted by jeanyves
    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.
    Thanks in advance.
    The problem is you are not actually linking in the libary, you need to compile your example program like so:
    Code:
    g++ -o example example.c -lpci
    As a side note, i typically find it useful to compile software with the -Wall flag, which basically means you will get extra warnings about problems in your code earlier on:

    Code:
    g++ -Wall -o example example.c -lpci


    Quote Originally Posted by jeanyves
    ((would it be possible to write back directly at : jean_yves_m@hotmail.com ? thanks))
    No, the idea of a forum is that discussions are open, everyone can contribute and learn from each other.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •