Pradipto Kolay <> Pradipto Kolay <>
Wed, 10 Jan 2001 04:25:20 GMT

[This message is sent through a WWW-Email gateway.]
[The authenticity of the sender can not be validated.]
[Message sent from the following machine - ]
[after accessing this URL]

 I am facing problems with dynamic linking under Linux. For example I have two programs , test.cxx and client.cxx. I compile test.cxx to get a shared library. Now test.cxx has a function called callme() which is not declared but not defined. I could compile this to get the .so. However , on trying to compile , client.cxx with this .so, I get undefined reference to callme(). Note that client.cxx DOES NOT call the function callme(). 
 Is there a way to go around this problem and get the linker to search for only those functions which are called ?
 I would be greatly indebted 2 U if U could suggest a way out.
 Thanking you in anticipation,
 Pradipto Kolay
 Design Engineer (Wipro GE Medical Systems)
 Code :
 Test.cxx -
 #include <iostream.h>
 char *printhello()
 cout << "Hello world " << endl << flush;
 void func()
 gcc -shared -embedded-relocs -o test.o
 (Works fine)
 client.cxx -
 #include <iostream.h>
 extern char *printhello(void );
 g++ -v client.cxx -L. -Bdynamic -lTest
 O/P :
 ./ undefined reference to `callme'
 collect2: ld returned 1 exit status
 g++: file path prefix `dynamic' never used