CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2009
    Posts
    46

    Question 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.

  2. #2
    Join Date
    Jun 2002
    Location
    Letchworth, UK
    Posts
    1,019

    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

  3. #3
    Join Date
    Jun 2009
    Posts
    46

    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

  4. #4
    Join Date
    Jun 2002
    Location
    Letchworth, UK
    Posts
    1,019

    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
  •  





Click Here to Expand Forum to Full Width

Featured