brucelane / android-cmake

Automatically exported from code.google.com/p/android-cmake
0 stars 0 forks source link

[PATCH] Use link_libraries for libstdc++ and libsupc++ #11

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hey,

This patch changes the toolchain file so that it links to libstdc++ and 
libsupc++ using link_libraries instead of CMAKE_*_LINKER_FLAGS. You'll notice 
that it also switches them around.

The reason this is needed is to fix issues arising when you try to link a 
program with a library built using ndk-build. I've attached a small test case 
reproducing the problem; in builds.sh you'll find several examples of build 
command lines. You'll see that putting the libraries before the object files 
(which using CMAKE_*_LINKER_FLAGS will naturally do) doesn't work, and putting 
the libraries in the other order doesn't work either. Thus, we need to use 
link_libraries (which puts the -l options after the object files), and change 
the libraries' order.

Just in case, I'm using a standalone toolchain extracted from NDK r8b.

Original issue reported on code.google.com by roman.do...@itseez.com on 9 Aug 2012 at 11:18

Attachments:

GoogleCodeExporter commented 8 years ago
1) link_libraries is deprecated for a good reason and you should never use it 
in new code.
2) the problem from your example will never happen with libsupc++ and libstdc++ 
because they are not regular libraries and g++ processes them specially. 
Normally you need not even reference them in command line because compiler 
loads them automatically. Thus latest commit completely removes lines you are 
trying to patch.
3) the toolchain support is preserved only for compatibility. So if you are 
building the whole project with CMake and need not support other build systems 
then you are recommended to use the cmake toolchain directly with NDK install.

Original comment by andrey.k...@itseez.com on 19 Aug 2012 at 5:32