Recursive linking

Sysprogs forums Forums VisualGDB Recursive linking

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #780
    ralphc
    Participant

    Hi,

    I’ve noticed that the –start-group and –end-group options include shared object library files as well as archive files. According to the Linux man page for ld, http://linux.die.net/man/1/ld , only archive files should be placed within these options. The reason I mention this, is that having so files within the –start-group/–end-group options caused my project to fail to link but when I manually moved the files to outside the options the build succeeded.

    I hope this is useful feedback.

    Ralph

    #3040
    support
    Keymaster

    Hi,

    We are putting –start-group/–end-group around all files because the -lXXX form can refer to either libXXX.a or libXXX.so depending on what is available in the library directories. We also tested it with shared libraries and did not encounter any problems.
    Could you please share a log showing the command line and the build error you encountered? If we could reproduce it on our side, we should be able to provide a solution that works for both cases.

    #3043
    ralphc
    Participant

    Hi,

    Sorry for the late response. Work has been really busy!

    I’ve put together a test application showing the issue. I’ve got an application called LibraryLinkApp. This application is dependent on a static library called StaticA. The static library is then dependent on an so called DynamicB. All three projects are stored within a single solution. I’ve set LibraryLinkApp’s dependencies so that it is dependent on the two libraries. I’ve set StaticA’s project settings so that it’s dependent on DynamicB. When I build the application I get undefined references to methods in the DynamicB library. The output from make is:

    
    g++ -o Debug/LibraryLinkingTest -Wl,-gc-sections    -Wl,--start-group Debug/LibraryLinkingTest.o  ../DynamicB/Debug/DynamicB.so ../StaticA/Debug/StaticA.a -Wl,--rpath='$ORIGIN' -Wl,--rpath='$ORIGIN/../../DynamicB/Debug/' -Wl,--rpath='$ORIGIN/../../StaticA/Debug/'  -Wl,--end-group
    ../StaticA/Debug/StaticA.a(A.o): In function `A::GetDependentClassName()':
    /opt/library_link_test/StaticA/A.cpp:15: undefined reference to `B::GetClassName()'
    ../StaticA/Debug/StaticA.a(A.o): In function `A::GetDependentLibraryName()':
    /opt/library_link_test/StaticA/A.cpp:20: undefined reference to `B::GetLibraryName()'
    collect2: ld returned 1 exit status
    make: *** [Debug/LibraryLinkingTest] Error 1
    

    However, if I move DynamicB.so to outside the –start/–end-group sections it compiles correctly. I hope this helps. If you need any further information let me know.

    Ralph

    #3041
    ralphc
    Participant

    Hi bazis,

    Have you or any of your colleagues had time to look at my previous post?

    Ralph

    #3042
    support
    Keymaster

    Hi,

    Sorry for the delay. Can you send us an archive with your test application (or attach it here) so that we could experiment with it on our side to figure out the root cause of the problem?

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.