Hello everyone,
I am meeting with a strange linking error when linking with a shared library on Linux platform. I use goo.c to generate libgoo.so, then write an application foo.c and link it with libgoo.so. The error occurs when linking with libgoo.so. The strange point is that, the LD_LIBRARY_PATH is not working, but -L option to gcc works -- I think they should be the same, but in my case below, it seems only -L works.
Here are the source codes,
goo.c
goo.hCode:int goo_export() { return 10; }
foo.cCode:int goo_export();
Error messages,Code:#include "goo.h" int main() { goo_export(); }
[root@localhost shared_goo]# gcc -shared goo.c -o libgoo.so
[root@localhost shared_goo]# export LD_LIBRARY_PATH=.
[root@localhost shared_goo]# gcc -I. -lgoo foo.c
/usr/bin/ld: cannot find -lgoo
collect2: ld returned 1 exit status
[root@localhost shared_goo]# gcc -I. -L. -lgoo foo.c
thanks in advance,
George



LinkBack URL
About LinkBacks


