On Tue, May 31, 2016 at 7:29 AM, Gregg Reynolds <dev at mobileink.com> wrote:
> Hi, > > Trying to target android from OS X I get the following error: > Ok, I got it to work. For the record: First edit resource/c_common/platform_features.h and change <stdassert.h> to <assert.h> Putting ANDROID_HOME in the env does not seem to work, you have to put it on the command line (see below). Darwin NDK: 1. cd extlibs/android/ndk 2. $ wget http://dl.google.com/android/ndk/android-ndk-r10d-darwin-x86_64.bin 1. $ chmod ug+x android-ndk-r10d-darwin-x86_64.bin 2. ./android-ndk-r10d-darwin-x86_64.bin Android SDK: if you don't already have it installed the build will prompt you. If you do have it installed, then export ANDROID_HOME=your/install/dir. Then check that you have the right versions: 1. $ANDROID_HOME/build-tools/20.0.0 - previously this was "android-4.4W", but the build system assumes it is "20.0.0". You can rename it, or run the SDK manager, delete it, and reinstall it 2. $ANDROID_HOME/platforms/android-21 BOOST: The build system only supports Linux at the moment, and extlibs/boost/SConscript throws an error if host_os is other than "linux2". After lots of trial and error I discovered the fix is very simple: if host_os == 'linux2' : boost_bootstrap = boost_base_name+os.sep+'bootstrap.sh' # BEGIN INSERT else : if host_os == 'darwin' : boost_bootstrap = '' # END INSERT else: msg="Host platform (%s) is currently not supported for boost builds" % host_os raise SCons.Errors.EnvironmentError(msg) Originally I tried setting boost_bootstrap = boost_base_name+os.sep+'bootstrap.sh' for darwin, but that does not work, as extlibs/boost/boost_1_58_0/bootstrap.sh generates site-config.jam, which sets target to darwin, overriding extlibs/boost/boost_1_58_0/tools/build/src/user-config.jam. The latter is generated by iotivity/tools/scons/BoostBuild.py, and sets up cross-compilation. bootstrap.sh is generated by tools/scons/BoostBootstrap.py, which is why we skip it. With target=darwin boost gets built, but the architecture is wrong so you'll end up with something like "ld: error: boost_thread: no archive symbol table (run ranlib)". If you want to see the build commands for boost, add "cmd.append('--debug-configuration')" to tools/scons/BoostBuild.py in the appropriate place. Maybe there's a better way to do this from the command line, but I'm a scons/boost neophyte and don't know a whole lot of Python. Also, the automatic download of boost did not work so I took the easy way out and used wget to fetch it and unzipped it in extlibs/boost. Now the build works (OS X 10.11.5, Java v. 1.8.0_91): $ scons SYS_VERSION=10.11 VERBOSE=true TARGET_OS=android TARGET_ARCH=x86 ANDROID_HOME=/Users/gar/android/sdk Unfortunately, that's only for x86, which does not work on my mobile, so I have not yet tested the output example apps. But they do build! The arm architectures do not work yet, I think the Boost build files need some work. I'll try to get it working today or tomorrow. Also, the generic-java branch with Petre Eftime's fixes does not yet build on OS X. I'm working on it. Hope that helps. If I can find some time I'll write up a proper blog post on it. I'd also be happy to work with the Android buildmeister on getting this into the codebase. -Gregg > > scons SYS_VERSION=10.11 VERBOSE=true TARGET_OS=android > ANDROID_HOME=/Users/gar/android/sdk > > ... > > /Users/gar/iotivity/iotivity/extlibs/android/ndk/android-ndk-r10d/toolchains/x86-4.8/prebuilt/darwin-x86_64/bin/i686-linux-android-g++ > -o out/android/x86/release/resource/src/liboc.so -Wl,--gc-sections > -Wl,-z,nocopyreloc > --sysroot=/Users/gar/iotivity/iotivity/extlibs/android/ndk/android-ndk-r10d/platforms/android-21/arch-x86 > -no-canonical-prefixes -Wl,-z,noexecstack -Wl,--no-undefined -Wl,-z,relro > -Wl,-z,now -s -Wl,-soname,liboc.so -shared > out/android/x86/release/resource/src/OCPlatform.os > out/android/x86/release/resource/src/OCPlatform_impl.os > out/android/x86/release/resource/src/OCResource.os > out/android/x86/release/resource/src/OCUtilities.os > out/android/x86/release/resource/src/OCException.os > out/android/x86/release/resource/src/OCRepresentation.os > out/android/x86/release/resource/src/InProcServerWrapper.os > out/android/x86/release/resource/src/InProcClientWrapper.os > out/android/x86/release/resource/src/OCResourceRequest.os > out/android/x86/release/resource/src/CAManager.os -Ldeps/android/lib/x86 > -Lextlibs/android/ndk/android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86 > -Ldep/android/x86/usr/lib -Lout/android/x86/release -L. > -Lresource/csdk/connectivity/lib/android > -Lout/android/x86/release/resource/csdk/logger -Lresource/csdk/logger > -Lout/android/x86/release/resource/c_common -Lresource/c_common > -Lout/android/x86/release/resource/csdk/routing -Lresource/csdk/routing > -lc_common -llogger -llog -lcoap -lc_compat -landroid_cpp11_compat > -lroutingmanager -loctbstack -loc_logger -lconnectivity_abstraction > -lboost_thread -lgnustl_shared > /Users/gar/iotivity/iotivity/extlibs/android/ndk/android-ndk-r10d/toolchains/x86-4.8/prebuilt/darwin-x86_64/bin/../lib/gcc/i686-linux-android/4.8/../../../../i686-linux-android/bin/ld: > error: boost_thread: no archive symbol table (run ranlib) > > Based on some stuff I found googling I thought setting env var $AR to the > ndk's i686-linux-android-ar might do the trick but it seemed to have no > effect. > > Or maybe it's my boost build. I just download boost to extlibs/boost and > unzipped it. Then at build time I see: > > bootstrapping using [extlibs/boost/boost_1_58_0.zip] ... > building boost from [extlibs/boost/boost_1_58_0/b2] for ... > Performing configuration checks > > - 32-bit : no (cached) > - 64-bit : yes (cached) > - arm : no (cached) > - mips1 : no (cached) > - power : no (cached) > - sparc : no (cached) > - x86 : yes (cached) > - lockfree boost::atomic_flag : yes (cached) > > Component configuration: > > - atomic : not building > - chrono : not building > - container : not building > - context : not building > - coroutine : not building > - date_time : building > - exception : not building > - filesystem : not building > - graph : not building > - graph_parallel : not building > - iostreams : not building > - locale : not building > - log : not building > - math : not building > - mpi : not building > - program_options : building > - python : not building > - random : not building > - regex : not building > - serialization : not building > - signals : not building > - system : building > - test : not building > - thread : building > - timer : not building > - wave : not building > > ...patience... > ...patience... > ...found 23636 targets... > ...updating 5 targets... > common.copy > /Users/gar/iotivity/iotivity/dep/android/x86/usr/include/boost/config.hpp > common.copy > /Users/gar/iotivity/iotivity/dep/android/x86/usr/include/boost/date_time.hpp > common.copy > /Users/gar/iotivity/iotivity/dep/android/x86/usr/include/boost/program_options.hpp > common.copy > /Users/gar/iotivity/iotivity/dep/android/x86/usr/include/boost/thread.hpp > common.copy > /Users/gar/iotivity/iotivity/dep/android/x86/usr/include/boost/variant.hpp > ...updated 5 targets... > > Does that look right? Anybody know what I need to do here to get unstuck? > > Thanks, > > Gregg > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.iotivity.org/pipermail/iotivity-dev/attachments/20160531/ce0d2552/attachment.html>
