Shared library, object files and undefined symbols problem?
Greetings all,
Please refer to image at:
http://i26.tinypic.com/fm2oas.jpg
In my project, I have two subprojects , one is 'mainapp' which is the executable and 'libSequential' which is a shared library.
I have declared and implemented some classes in 'mainapp' project (TrainData,TrainDaraRow,TrainDataRowCell)
'mainapp' loads 'libSequential' dynamically and invoke methods in it. (illustrated in codesnippet in blue)
'libSequential' includes the headers from 'mainapp' ,but when building, it does not link the object files of the classes (TrainData.o,TrainDataRow.so,TrainDataRowCell.o).
So , my problem is eventhough 'libSequential' compiles , during runtime ,that is when 'mainapp' tries to load, it gives 'undenifed symbol' error.
I dont want to link object files with 'libSequential' because I think it is reduntant(since they are inside 'mainapp')
Is there a way for 'libSequential.so' to use the object files in 'mainapp'?
Thanks in advance.
Re: Shared library, object files and undefined symbols problem?
Type ldd mainapp
It should tell you what mainapp can see.
You probably need to put the directory containing libSequential.so in LD_LIBRARY_PATH. If you're using HPUX-10, it is LIBPATH.
Re: Shared library, object files and undefined symbols problem?
Hi
thank you for the reply.
I use LD_LIBRARY_PATH and the library loads well.But the problem is, some of the classes are implemented and *linked* against the 'mainapp' application ,and not linked with 'libSequential.so' . But inside 'libSequential.so' it uses those classes.During the compile time it doesnot throw any error because (i guess) I am building a shared library.
But during run time 'libSequential.so' cannot find those classes which I thought would refer classes which are linked again 'mainapp'.
thanks
Re: Shared library, object files and undefined symbols problem?
It could be a name mangling problem. Change your libSequential code to
Code:
extern "C" void libMethod()
{
...
}