[cmake-developers] Apple tests for target_link_libraries failing

Rolf Eike Beer eike at sf-mail.de
Thu Oct 13 12:00:23 EDT 2011


> Rolf Eike Beer wrote:
>
>>> I'm not certain that's correct though. Those flags don't seem to be
>>> used
>>> when I build. I also don't know what those flags do.
>>>
>>> Linking CXX executable exec
>>> /home/stephen/dev/qt48/kde/bin/cmake -E cmake_link_script
>>> CMakeFiles/exec.dir/link.txt --verbose=1
>>> /usr/lib/icecc/bin/c++       CMakeFiles/exec.dir/main.cpp.o  -o exec -
>>> rdynamic lib/liblibC.so
>>> -Wl,-rpath,/home/stephen/cmaketest/test19/build/lib
>>> -Wl,-rpath-link,/home/stephen/cmaketest/test19/build/lib
>>> CMakeFiles/exec.dir/main.cpp.o:main.cpp:function main: error: undefined
>>> reference to 'classB::classB()'
>>> collect2: ld returned 1 exit status
>>> make[2]: *** [exec] Error 1
>>> make[2]: Leaving directory `/home/stephen/cmaketest/test19/build'
>>
>> Maybe this is just the default setting for your binutils. Try
>> LDFLAGS=-Wl,--copy-dt-needed-entries,-no-as-needed and see what happens.
>> I
>> bet this will change the behavior on your system.
>
> ld now gives a new error:
>
> /usr/bin/ld: error: --copy-dt-needed-entries is not supported but is
> required for liblibA.so in lib/liblibC.so
>
> Here's a more complete fragment:
>
> Linking CXX executable exec
> /home/stephen/dev/qt48/kde/bin/cmake -E cmake_link_script
> CMakeFiles/exec.dir/link.txt --verbose=1
> /usr/lib/icecc/bin/c++      -Wl,--copy-dt-needed-entries,-no-as-needed
> CMakeFiles/exec.dir/main.cpp.o  -o exec -rdynamic lib/liblibC.so -Wl,-
> rpath,/home/stephen/cmaketest/test19/build/lib -Wl,-rpath-
> link,/home/stephen/cmaketest/test19/build/lib
> /usr/bin/ld: error: --copy-dt-needed-entries is not supported but is
> required for liblibA.so in lib/liblibC.so
> CMakeFiles/exec.dir/main.cpp.o:main.cpp:function main: error: undefined
> reference to 'classB::classB()'
> collect2: ld returned 1 exit status
>
> I also ran ctest -V -R target_link_librares with those flags and many more
> tests failed.
>
> I have no idea what those flags do, so I don't know if that new error is a
> lead.

This may be new in my binutils version. Can you just try
LDFLAGS=-Wl,-no-as-needed?

Eike



More information about the cmake-developers mailing list