-
August 12th, 2009, 10:33 PM
#1
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.
-
August 20th, 2009, 07:18 AM
#2
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.
Succinct is verbose for terse
-
August 20th, 2009, 08:07 PM
#3
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
-
August 21st, 2009, 01:58 PM
#4
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()
{
...
}
Succinct is verbose for terse
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|