[CMake] linking with .so w/ non-standard names
Kenneth Chang
kchang at athenacr.com
Mon Aug 17 10:53:02 EDT 2009
Hi Bill,
I tried the same experiment with a boost .so and it worked. What's
interesting is that I can link with thostmduserapi.so if I do it
manually or just renamed it, and the application works, so it looks like
the file is a valid object. gcc/c++ doesn't complain about a bad object
either. How does cmake determine that a file is an object it can use on
the link line? This is a third party .so, so I'm not quite sure what
they did to build it, but it's likely they did something strange.
Kenny
Bill Hoffman wrote:
> Kenneth Chang wrote:
>> I manufactured a simple setup to demonstrate what I have. I hope
>> this helps.
>>
> ...
>
> Is /home/kchang/sandbox/thost/thostmduserapi.so a valid object? I
> was able to reproduce what you had if I did this:
>
> cmake_minimum_required(VERSION 2.6.4)
> add_executable(foo foo.c)
> target_link_libraries(foo /home/hoffman/foo/foo.so)
>
>
> If I copied a valid .so from /usr/lib
> cp /usr/lib/libmpi.so ../foo.so
>
> I get this:
>
> /usr/bin/gcc -o CMakeFiles/foo.dir/foo.c.o -c
> /home/hoffman/foo/foo.c
> Linking C executable foo
> /home/hoffman/CMake26-build/bin/cmake -E cmake_link_script
> CMakeFiles/foo.dir/link.txt --verbose=1
> /usr/bin/gcc -fPIC CMakeFiles/foo.dir/foo.c.o -o foo -rdynamic
> ../foo.so -Wl,-rpath,/home/hoffman/foo
> make[2]: Leaving directory `/home/hoffman/foo/b'
>
> If I remove the file and create a bogus one:
> rm ../foo.so
> touch ../foo.so
>
> Then I get the split:
>
> make[2]: Leaving directory `/home/hoffman/foo/b'
> make -f CMakeFiles/foo.dir/build.make CMakeFiles/foo.dir/build
> make[2]: Entering directory `/home/hoffman/foo/b'
> Linking C executable foo
> /home/hoffman/CMake26-build/bin/cmake -E cmake_link_script
> CMakeFiles/foo.dir/link.txt --verbose=1
> /usr/bin/gcc -fPIC CMakeFiles/foo.dir/foo.c.o -o foo -rdynamic
> -L/home/hoffman/foo -lfoo -Wl,-rpath,/home/hoffman/foo
> /home/hoffman/foo/libfoo.so: file not recognized: File truncated
>
>
> -Bill
>
>
>
More information about the CMake
mailing list