message

Pradipto Kolay <pradipto.kolay@geind.ge.com> Pradipto Kolay <pradipto.kolay@geind.ge.com>
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 - 64.208.99.35 ]
[after accessing this URL http://www.dcs.gla.ac.uk/scripts/global/send_message?glasgow-haskell-users@dcs.gla.ac.uk+message]
--

Hi,
 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)
 Pradipto.kolay@geind.ge.com
 
 Code :
 Test.cxx -
 #include <iostream.h>
 char *printhello()
 {
 cout << "Hello world " << endl << flush;
 }
 
 void func()
 {
 callme();
 }
 
 gcc -shared -embedded-relocs -o libTest.so test.o
 (Works fine)
 client.cxx -
 #include <iostream.h>
 extern char *printhello(void );
 main()
 {
 printhello();
 }
 
 g++ -v client.cxx -L. -Bdynamic -lTest
 O/P :
 ./libTest.so: undefined reference to `callme'
 collect2: ld returned 1 exit status
 g++: file path prefix `dynamic' never used

--