New question #76755 on Ubuntu:
https://answers.launchpad.net/ubuntu/+question/76755

I have a C++ program written several years ago which uses the pcilib library 
and was last compiled by g++ in 2006.  I am running Jaunty on an amd64, also 
tried on a 32-bit Celeron with the same result.

Trying to recompile under the current g++, after fixing a few minor issues that 
changes in the language could reasonably be expected to introduce, such as 
adding #include<cerrno>, the source compiles, but the link phase gives errors.

pupo...@puposet:~/Documents/Projects/BabyTog/2006software$ make
g++ -o../bin/tog tog.o blue.o ring.o -lpci 
blue.o: In function `adc::adc()':
blue.cpp:(.text+0x6e0): undefined reference to `pci_alloc()'
blue.cpp:(.text+0x726): undefined reference to `pci_init(pci_access*)'
blue.cpp:(.text+0x72e): undefined reference to `pci_scan_bus(pci_access*)'
blue.cpp:(.text+0x773): undefined reference to `pci_fill_info(pci_dev*, int)'
blue.cpp:(.text+0x790): undefined reference to `pci_cleanup(pci_access*)'
blue.cpp:(.text+0x7b1): undefined reference to `pci_cleanup(pci_access*)'
blue.o: In function `adc::adc()':
blue.cpp:(.text+0x86c): undefined reference to `pci_alloc()'
blue.cpp:(.text+0x8b2): undefined reference to `pci_init(pci_access*)'
blue.cpp:(.text+0x8ba): undefined reference to `pci_scan_bus(pci_access*)'
blue.cpp:(.text+0x903): undefined reference to `pci_fill_info(pci_dev*, int)'
blue.cpp:(.text+0x920): undefined reference to `pci_cleanup(pci_access*)'
blue.cpp:(.text+0x941): undefined reference to `pci_cleanup(pci_access*)'
collect2: ld returned 1 exit status
make: *** [tog] Error 1

The packages g++, pciutils and libpci-dev are installed and nm shows that 
/lib/libpci.so does indeed provide the missing routines.

Testing with the simple C pci example provided with the library (but for some 
reason deleted from the Ubuntu version, which is a shame because it is the only 
extant documentation of the procedure usage) I find that it comp[iles and runs 
correctly if compiled with gcc, but produces the same errors if compiled with 
g++. So:

pupo...@puposet:~/Downloads/pci/pciutils-3.1.3$ gcc -o example example.c -lpci
pupo...@puposet:~/Downloads/pci/pciutils-3.1.3$ 

is OK but

pupo...@puposet:~/Downloads/pci/pciutils-3.1.3$ g++ -o example example.c -lpci
/tmp/ccxOw8m4.o: In function `main':
example.c:(.text+0x1e): undefined reference to `pci_alloc()'
example.c:(.text+0x31): undefined reference to `pci_init(pci_access*)'
example.c:(.text+0x3d): undefined reference to `pci_scan_bus(pci_access*)'
example.c:(.text+0x65): undefined reference to `pci_fill_info(pci_dev*, int)'
example.c:(.text+0x76): undefined reference to `pci_read_byte(pci_dev*, int)'
example.c:(.text+0x178): undefined reference to `pci_lookup_name(pci_access*, 
char*, int, int, ...)'
example.c:(.text+0x1c0): undefined reference to `pci_cleanup(pci_access*)'
collect2: ld returned 1 exit status

Isn't, although again there is no problem with compilation, it just fails to 
link.
It looks like some sort of problem with the name mangling.


Tim Jackson

-- 
You received this question notification because you are a member of UF
Unanswered Posts Team, which is an answer contact for Ubuntu.

_______________________________________________
Mailing list: https://launchpad.net/~ubuntuforums-unanswered
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~ubuntuforums-unanswered
More help   : https://help.launchpad.net/ListHelp

Reply via email to