Can't solve gcc linking error, please help.

  • Thread starter Thread starter b2rdark
  • Start date Start date
B

b2rdark

Hi!

I'm trying to compile a very simple code which uses functions defined in the Linux PCI Utilities library, but the linker stops with "undefined reference to" errors and im running out of ideas. I'm on ubuntu 14.04 LTS (64-bit) and i've installed the libpci-dev (1:3.2.1-1ubuntu5) package too.

Here is my test.c:
Code:
#include <pci/pci.h>

int main(int argc, char *argv[]){

struct pci_access *pci = pci_alloc();
pci_cleanup(pci);
return 0;
}
And the compiler output:
Code:
/home/dark/Temp/libpci-test# make
gcc -O3 -Wall -c test.c
gcc -O3 -Wall -lpci -o test test.o
test.o: In function `main':
test.c:(.text.startup+0x5): undefined reference to `pci_alloc'
test.c:(.text.startup+0xd): undefined reference to `pci_cleanup'
collect2: error: ld returned 1 exit status
make: *** [test] Error 1
But these functions seem to be there..
Code:
/home/dark/Temp/libpci-test# nm -D /usr/lib/x86_64-linux-gnu/libpci.so
U access
U close
U closedir
U __ctype_b_loc
w __cxa_finalize
U __errno_location
U exit
U fclose
U ferror
U fflush
U fgets
U fopen
U __fprintf_chk
U fputc
U free
U fwrite
U gethostname
U getpid
U getpwuid
U getuid
w __gmon_start__
U gzclose
U gzeof
U gzerror
U gzgets
U gzopen
U __h_errno_location
U iopl
U __isoc99_sscanf
w _ITM_deregisterTMCloneTable
w _ITM_registerTMCloneTable
w _Jv_RegisterClasses
0000000000000000 A LIBPCI_3.0
0000000000000000 A LIBPCI_3.1
0000000000000000 A LIBPCI_3.2
U malloc
U memcmp
U memcpy
U __memcpy_chk
U memset
U open
U __open_2
U opendir
00000000000027e0 T pci_alloc
0000000000002a20 T pci_cleanup
0000000000002f80 T pci_fill_info
0000000000002f80 T pci_fill_info
0000000000002f80 T pci_fill_info
0000000000004c60 T pci_filter_init
0000000000005040 T pci_filter_match
0000000000004f20 T pci_filter_parse_id
0000000000004c90 T pci_filter_parse_slot
0000000000006950 T pci_find_cap
0000000000002bf0 T pci_free_dev
0000000000005980 T pci_free_name_list
0000000000002bb0 T pci_get_dev
00000000000027b0 T pci_get_method_name
00000000000066d0 T pci_get_param
00000000000063b0 T pci_id_cache_flush
0000000000002890 T pci_init
00000000000059d0 T pci_load_name_list
0000000000002760 T pci_lookup_method
00000000000043c0 T pci_lookup_name
0000000000002db0 T pci_read_block
0000000000002c30 T pci_read_byte
0000000000002d20 T pci_read_long
0000000000002dc0 T pci_read_vpd
0000000000002c90 T pci_read_word
0000000000002a90 T pci_scan_bus
00000000000059a0 T pci_set_name_list_path
0000000000006820 T pci_set_param
0000000000002fe0 T pci_setup_cache
0000000000006880 T pci_walk_params
0000000000002f20 T pci_write_block
0000000000002de0 T pci_write_byte
0000000000002ea0 T pci_write_long
0000000000002e20 T pci_write_word
U pread
U pwrite
U read
U readdir
U rename
U __res_init
U __res_query
U snprintf
U __snprintf_chk
U __sprintf_chk
U sscanf
U __stack_chk_fail
U stderr
U stdout
U strchr
U strcmp
U __strdup
U strerror
U strlen
U strrchr
U strtol
U unlink
U __vfprintf_chk
U zError
What am I doing wrong?

Continue reading...
 
Back
Top