// --------------------------------------------------------
// Project:
// Purpose: openFrameworks + Android + Cygwin Guide
// Author: Ho-Jung Kim (godmode2k@hotmail.com)
// Date: March 27, 2013
// Filename: openFrameworks + Android + Cygwin Guide.txt
// --------------------------------------------------------
// NOTE:
// --------------------------------------------------------
// --------------------------------------------------------
// Prerequisites (My environment)
// --------------------------------------------------------
- Windows 7 x64
- openFrameworks: of_v0.7.4_android_release
- Eclipse: eclipse-mobile-juno-SR1-win32-x86_64
- Android NDK: Android-NDK-r8d
- Android SDK: Latest version
- JDK: Either 1.6 or 1.7
- Cygwin: Any version with build essentials all
(My env: CYGWIN_NT-6.1-WOW64 xxx 1.7.9(0.237/5/3) xxx i686 Cygwin)
- Installation
1. Install Cygwin
- C:/cygwin or whereever
2. Install JDK
3. Install Eclipse
4. Install Android NDK
- C:/cygwin/ndk (Easy...)
5. Install Android SDK
6. Install ADT Plugin in Eclipse
- ADT Plugin URL: https://dl-ssl.google.com/android/eclipse/
-
- SEE google android online guide
- http://developer.android.com/sdk/index.html
- http://developer.android.com/sdk/installing/installing-adt.html
SEE this comment "# hjkim: Cygwin: ADD []" for add or comment out
// --------------------------------------------------------
// 1. Set Cygwin path
// --------------------------------------------------------
Windows environment
[CYGWIN_HOME]: C:\cygwin
[Path]: ;%CYGWIN_HOME%;%CYGWIN_HOME%\bin;%CYGWIN_HOME%\usr\bin;~~windows~~
// --------------------------------------------------------
// 2. Eclipse environment
// --------------------------------------------------------
[Window -> Preferences]
2.1 C/C++ -> Build -> Build Variables
- Check the [Show system variables]
- Move "C:\cygwin\bin" up to the top
2.2. C/C++ -> Debug -> Source Lookup Path
- [Add] -> select the type "Path Mapping"
Specify the mapping paths
- Name: "Cygwin" or you want
- Compilation path: "c:\cygwin\c"
- Local file system path: select the your src drive "C:\"
// --------------------------------------------------------
// 3. Make custom toolchain
// --------------------------------------------------------
Toolchain named "of_arm-linux-androideabi-4.6" here
$ /android-ndk-r8d/build/tools/make-standalone-toolchain.sh --platform=android-8 --install-dir=/ndk/toolchains/of_arm-linux-androideabi-4.6/prebuilt/windows
Build test:
// test_of.cpp
// stdc++
#include < iostream >
#include < typeinfo >
// stdc
#include < stdio.h >
#include < unistd.h >
int main(void) {
return 0;
}
$ /ndk/toolchains/of_arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-g++ -I/ndk/toolchains/of_arm-linux-androideabi-4.6/prebuilt/windows/include -o test_of.o test_of.cpp -Wall
// --------------------------------------------------------
// 4. Comment out around the below due to avoid multiple definition of the "__dso_handle"
// --------------------------------------------------------
"__dso_handle" defined into "crtbegin_so.o" already
SEE: custom toolchain directory
/ndk/toolchains/of_arm-linux-androideabi-4.6/prebuilt/windows/sysroot/usr/lib
of_v0.7.4_android_release/addons/ofxAndroid/src/ofxAndroidUtils.cpp
/*
// fix for undefined symbols from ndk r8c
extern "C" {
extern void *__dso_handle __attribute__((__visibility__ ("hidden")));
void *__dso_handle;
}
*/
SEE its log
// History: http://stuff.mit.edu/afs/sipb/project/android/docs/tools/sdk/ndk/index.html
If your project is linked with the -nostdlib -Wl,--no-undefined options, you must provide your own __dso_handle because crtbegin_so.o is not linked in this case. The content of __dso_handle does not matter, as shown in the following example code:
extern "C" {
extern void *__dso_handle __attribute__((__visibility__ ("hidden")));
void *__dso_handle;
}
// --------------------------------------------------------
// 5. Makefile: Comment out and adds
// --------------------------------------------------------
Checks uname on Cygwin shell
$ uname
CYGWIN_NT-6.1-WOW64
of_v0.7.4_android_release/libs/openFrameworksCompiled/project/android/
[makefile]
{
...
else ifeq ($(shell uname),MINGW32_NT-6.1)
HOST_PLATFORM = windows
# hjkim: Cygwin: ADD [
else ifeq ($(shell uname),CYGWIN_NT-6.1-WOW64)
HOST_PLATFORM = windows
# hjkim: Cygwin: ADD ]
else
HOST_PLATFORM = linux-x86
endif
...
# hjkim: Cygwin: ADD [
# TOOLCHAIN=arm-linux-androideabi-$(GCC_VERSION)
TOOLCHAIN=of_arm-linux-androideabi-$(GCC_VERSION)
# hjkim: Cygwin: ADD ]
...
# hjkim: Cygwin: ADD [
# SYSROOT=$(NDK_ROOT)/platforms/$(NDK_PLATFORM)/arch-arm/
# CFLAGS += -nostdlib --sysroot=$(SYSROOT) -fno-short-enums -frtti -fexceptions
# CFLAGS += -I"$(NDK_ROOT)/platforms/$(NDK_PLATFORM)/arch-arm/usr/include/" -I"$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/include" -I"$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(GCC_VERSION)/include" -I"$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/libs/$(ABI)/include" -I"$(NDK_ROOT)/sources/crystax/include/" -I"$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(GCC_VERSION)/libs/$(ABI)/include"
CFLAGS += -fno-short-enums -frtti -fexceptions
HEADER = -I"$(NDK_ROOT)/platforms/$(NDK_PLATFORM)/arch-arm/usr/include/" -I"$(NDK_ROOT)/toolchains/$(TOOLCHAIN)/prebuilt/$(HOST_PLATFORM)/include/"
CFLAGS += $(HEADER) -I"$(NDK_ROOT)/sources/crystax/include/"
# hjkim: Cygwin: ADD ]
...
}
-------------------
of_v0.7.4_android_release/libs/openFrameworksCompiled/project/android/
[paths.make] // copy from paths.make.default
{
...
# hjkim: Cygwin: ADD [
NDK_ROOT=/ndk
SDK_ROOT=/cygdrive/c/Java/android/android-sdk-windows
ANT_HOME=/cygdrive/c/Java/apache-ant-1.8.1
ANT_BIN=$(ANT_HOME)/bin/
# hjkim: Cygwin: ADD ]
}
-------------------
of_v0.7.4_android_release/libs/openFrameworksCompiled/project/makefileCommon/
[Makefile.android]
{
...
# hjkim: Cygwin: ADD [
#TOOLCHAIN=arm-linux-androideabi-$(GCC_VERSION)
TOOLCHAIN=of_arm-linux-androideabi-$(GCC_VERSION)
# hjkim: Cygwin: ADD ]
...
# hjkim: Cygwin: ADD [
#SYSROOT=$(NDK_ROOT)/platforms/$(NDK_PLATFORM)/arch-arm/
#CFLAGS += -nostdlib --sysroot=$(SYSROOT) -fno-short-enums
#CFLAGS += -I"$(NDK_ROOT)/platforms/$(NDK_PLATFORM)/arch-arm/usr/include/" -I"$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/include" -I"$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(GCC_VERSION)/include" -I"$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/libs/$(ABI)/include" -I"$(NDK_ROOT)/sources/crystax/include/" -I"$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(GCC_VERSION)/libs/$(ABI)/include"
CFLAGS += -fno-short-enums
HEADER = -I"$(NDK_ROOT)/platforms/$(NDK_PLATFORM)/arch-arm/usr/include/" -I"$(NDK_ROOT)/toolchains/$(TOOLCHAIN)/prebuilt/$(HOST_PLATFORM)/include/"
CFLAGS += $(HEADER) -I"$(NDK_ROOT)/sources/crystax/include/"
# hjkim: Cygwin: ADD ]
...
# hjkim: Cygwin: ADD [
#LDFLAGS = --sysroot=$(SYSROOT) -nostdlib -L"$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(GCC_VERSION)/libs/$(ABI)"
# hjkim: Cygwin: ADD ]
...
# hjkim: Cygwin: ADD [
#SYSTEMLIBS += -lsupc++ -lz -lGLESv1_CM -llog -ldl -lm -lc $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(GCC_VERSION)/libs/$(ABI)/libgnustl_static.a -lgcc
SYSTEMLIBS += -lsupc++ -lz -lGLESv1_CM -llog -ldl -lm -lc -lgcc
# hjkim: Cygwin: ADD ]
...
}
-------------------
of_v0.7.4_android_release/libs/openFrameworksCompiled/project/makefileCommon/
[Makefile.examples]
{
...
else
HOST_PLATFORM = linux-x86
endif
endif
# hjkim: Cygwin: ADD [
include $(OF_ROOT)/libs/openFrameworksCompiled/project/android/paths.make
ARCH = android
HOST_PLATFORM = windows
# hjkim: Cygwin: ADD ]
ifndef ARCH
ARCH=$(shell uname -m)
endif
...
}
// --------------------------------------------------------
// 6. Build all in Eclipse
// --------------------------------------------------------
- import project
1. import of_src/libs
2. import of_src/addons/ofxAndroid/ofAndroidLib
3. import of_src/libs/openFrameworks
4. import of_src/examples/android/*
- build
1. ofAndroidLib
2. openFrameworks
3. examples
- have a fun!
__EOF__