Home Ask Login Register

Developers Planet

Your answer is one click away!

Droid Coder February 2016

Cross-compiling package with CMake: how to set linker path to find compiler support library?

I'm trying to cross-compile the qhull library for Android, on a Linux x86-64 host. I'm fairly new to CMake, but rather experienced with other buildsystem tools.

I've setup a toolchain file, according to all the recommendations I've found, and it has worked for several other packages. Yet, no matter what I try, nothing seems to augment the linker path for one or more of qhull's executable programs. The problem is that it can't find Android NDK's libsup++.a, which is an implicit dependency of its compiler (GCC). If I take the generated link command and manually add -Lpath_to_libsup++.a, then the link succeeds.

In my toolchain file, among the things I've tried are:

  • link_directories()

I don't see anything unusual about its CMakeLists.txt, at least with respect to the first point of failure (user_eg3).

I'd prefer not to patch the library, if possible. I know many others are using this on Android (it's a dependency of point cloud library), so I assume I'm probably missing a step.

BTW, I'm using CMake v3.4.3, Android NDK r10e, and qhull v7.2.0.


Droid Coder February 2016

I found a workaround.

In this post, Florian mentioned that CMake internally sets CMAKE_EXE_LINKER_FLAGS_INIT to $ENV{LDFLAGS}. I've found that if I set the environment variable LDFLAGS=-Lpath_to_libsup++.a, it gets passed through to the link command, which now succeeds.

I'd still like to know the proper CMake solution to this problem. Or, if the problem lies with qhull, then maybe someone can peek at its CMakeLists.txt (linked above) and point out what it's doing wrong.

Post Status

Asked in February 2016
Viewed 3,111 times
Voted 12
Answered 1 times


Leave an answer

Quote of the day: live life