Reputation: 8819
I'm attempting to build a library for x86 distributions of the android emulator using the android ndk. The library uses scons for building and has a bunch of stl and boost dependencies. So far, I've set --cxx and --cc to the compilers that come with the android toolchain, and set the sysroot for gcc to the platform specific root that comes with the ndk.
Right now, I'm getting errors like error: ctime: No such file or directory etc. I see that there are .a and .so files in the android ndk for the stl library, how do I ask scons/the compiler to link against these?
Upvotes: 4
Views: 1071
Reputation: 10357
You'll have to configure the library paths, which are the traditional "-L" flags passed to the compiler, gcc in this case. (Should you be using g++
instead of gcc
?)
This is done by setting the LIBPATH
SCons construction variable, as mentioned here. Notice that SCons does this in a portable manner, so you dont need to specify the -L
in the paths. Here is an excerpt of how I typically do this:
libPaths = [
'/pathToNDK/build/cxx-stl/gnu-libstdc++/lib',
'/anotherLibPath',
'/and/yet/another'
]
includePaths = [
'/pathToNDK/build/cxx-stl/gnu-libstdc++/include',
'/anotherIncludePath',
'/and/yet/another/include'
]
env.Append(LIBPATH = libPaths, CPPPATH = includePaths)
env.Library(target='yourTarget', source = 'sourceFile.cc')
env.Program(target='yourBinary', source = 'yourSource')
Notice I also included how to specify the include paths (the traditional "-I" flags that are passed to the compiler). This is appending the specified include and library paths to the environment. If you dont want to append, use env.Replace()
instead. Now all builders on the same env will use those paths, in this example both the Library()
and Program()
builders will use the specified paths.
Also, if the paths you want to use are inside the project directory (in the same dir or a subdir of the SConstruct) then you dont need to use the complete absolute path, but can prepend '#' and specify the path relative to the root level SConstruct.
Upvotes: 1