boost for android building boost log - android

I am trying to build boost 1.54 for android. I am able to do it for date_time, filesystem, regex, program_options, signals, system and thread libraries of boost. But if I add boost log library among these, build fails as saying 'failed updating 8 targets'.
I appended following lines to my user-config.jam
import os ;
androidNDKRoot = C:/android-ndk-r8e ; # put the relevant path
using gcc : android :
$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.7/prebuilt/windows/bin/arm-linux-androideabi-g++ :
<compileflags>--sysroot=$(androidNDKRoot)/platforms/android-8/arch-arm
<compileflags>-mthumb
<compileflags>-Os
<compileflags>-fno-strict-aliasing
<compileflags>-O2
<compileflags>-DNDEBUG
<compileflags>-g
<compileflags>-lstdc++
<compileflags>-I$(androidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.7/include
<compileflags>-I$(androidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi/include
<compileflags>-D__GLIBC__
<compileflags>-D_GLIBCXX__PTHREADS
<compileflags>-D__arm__
<compileflags>-D_REENTRANT
<archiver>$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.7/prebuilt/windows/bin/arm-linux-androideabi-ar
<ranlib>$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.7/prebuilt/windows/bin/arm-linux-androideabi-ranlib
;
I also changed libs/filesystem/src/operations.cpp file in order to compile threading libraries. You can find the necessary change here.
My build command is as following
set CXXFLAGS="-I%ANDROID_NDK%/platforms/android-8/arch-arm/usr/include -I%ANDROID_NDK%/sources/cxx-stl/gnu-libstdc++/4.4.3/include -I%ANDROID_NDK%/sources/cxx-stl/gnu-libstdc++/4.4.3/libs/armeabi/include "
set TOOLSET=gcc-android
.\b2 --toolset=%TOOLSET% --user-config=./user-config-android.jam cxxflags=%CXXFLAGS% threadapi=pthread --prefix=..\boost_android_arm --builddir=./ target-os=linux --with-date_time --with-filesystem --with-regex --with-log define=BOOST_FILESYSTEM_VERSION=3 --with-program_options --with-signals --with-system --with-thread link=static runtime-link=shared threading=multi install
As I already told before, it does compile if I don't type --with-log at build command.
Here are couple of lines from output,
gcc.compile.c++ bin.v2\libs\log\build\gcc-android\release\build-no\link-static\log-api-unix\target-os-linux\threadapi-pthread\threading-multi\attribute_name.o
In file included from libs\log\src\attribute_name.cpp:32:0:
./boost/log/detail/light_rw_mutex.hpp:131:5: error: 'pthread_rwlock_t' does not name a type
./boost/log/detail/light_rw_mutex.hpp: In constructor 'boost::log::v2s_mt_posix::aux::light_rw_mutex::light_rw_mutex()':
./boost/log/detail/light_rw_mutex.hpp:136:30: error: 'm_Mutex' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp:136:43: error: 'pthread_rwlock_init' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp: In destructor 'boost::log::v2s_mt_posix::aux::light_rw_mutex::~light_rw_mutex()':
./boost/log/detail/light_rw_mutex.hpp:140:33: error: 'm_Mutex' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp:140:40: error: 'pthread_rwlock_destroy' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp: In member function 'void boost::log::v2s_mt_posix::aux::light_rw_mutex::lock_shared()':
./boost/log/detail/light_rw_mutex.hpp:144:32: error: 'm_Mutex' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp:144:39: error: 'pthread_rwlock_rdlock' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp: In member function 'void boost::log::v2s_mt_posix::aux::light_rw_mutex::unlock_shared()':
./boost/log/detail/light_rw_mutex.hpp:148:32: error: 'm_Mutex' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp:148:39: error: 'pthread_rwlock_unlock' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp: In member function 'void boost::log::v2s_mt_posix::aux::light_rw_mutex::lock()':
./boost/log/detail/light_rw_mutex.hpp:152:32: error: 'm_Mutex' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp:152:39: error: 'pthread_rwlock_wrlock' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp: In member function 'void boost::log::v2s_mt_posix::aux::light_rw_mutex::unlock()':
./boost/log/detail/light_rw_mutex.hpp:156:32: error: 'm_Mutex' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp:156:39: error: 'pthread_rwlock_unlock' was not declared in this scope
It includes many lines like these, but these are the first error that it gave.
Can someone see what I did wrong or what should I change?
Thanks

Just changing platform to android-9 solved the problem.
After that it gaves another error which is already fixed in here

Related

Error when adding ofxPd to existing openframeworks android project: Undefined symbols for architecture x86_64

I've have built an android application with OF and I want to add functionalities from ofxPd. The application works until I add ofxPd.
I have added the ofxPd folder to the addons folder of my project and also the path to the header search paths. I have also added the other C flags (-DPD -DHAVE_UNISTD_H -DUSEAPI_DUMMY).
However, I cannot make it work, I get this error and I do not know how to solve?
Undefined symbols for architecture x86_64:
"ofApp::audioReceived(float*, int, int)", referenced from:
vtable for ofApp in ofApp.o
"ofApp::audioRequested(float*, int, int)", referenced from:
vtable for ofApp in ofApp.o
"non-virtual thunk to ofApp::audioRequested(float*, int, int)", referenced from:
vtable for ofApp in ofApp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Could you tell me what I am doing wrong or what can I do to solve it?
If, as suggested in here, I create a new project, I add the same addons, and I replace the code in the files main.cpp, ofApp.cpp and ofApp.h, I get the error: "ofxSpatialHash.h" file not found
Q:
Can you run one of the ofxPD examples without problems?
Some initial stuff you could try :
I see you might be missing a needed flag: DHAVE_ALLOCA_H
Are you sure "audioReceived" is defined in the ofApp.cpp file?
In my experience "non-virtual thunk…" means in general that there is a virtual member function defined that is not implemented… (hence the vtable error).
References
https://github.com/danomatika/ofxPd

C, Android NDK: import own input.h version containing missing declarations

I'm trying to get the Eventinjector project from pocketmagic.net found here.
This means working with a precoded jni library writen in C. My problem is that I get some build errors when I try to compile the native code. The error log is long and I believe all errors are the same, therefore I'll only post part of it.
jni/EventInjector.h:718:9: error: (near initialization for 'mt_tool_labels[0].value')
jni/EventInjector.h:719:9: error: 'MT_TOOL_PEN' undeclared here (not in a function)
jni/EventInjector.h:719:9: error: initializer element is not constant
jni/EventInjector.h:719:9: error: (near initialization for 'mt_tool_labels[1].value')
jni/EventInjector.h:720:9: error: 'MT_TOOL_MAX' undeclared here (not in a function)
jni/EventInjector.h:720:9: error: initializer element is not constant
jni/EventInjector.h:720:9: error: (near initialization for 'mt_tool_labels[2].value')
jni/EventInjector.c: In function 'debug':
jni/EventInjector.c:82:2: error: format not a string literal and no format arguments [- Werror=format-security]
cc1.exe: some warnings being treated as errors
make: *** [obj/local/armeabi/objs/EventInjector/EventInjector.o] Error 1
Going throught the comments under the blogpost I discovered that "Alessandro" had the same problem but had found a solution. (post 51) " I had the same issue and imported my own input.h version containing all the missing declarations."
This is the part of the .c file that generates most of the errors:
static struct label key_labels[] = {
LABEL(KEY_RESERVED),
LABEL(KEY_ESC),
LABEL(KEY_1),
LABEL(KEY_2),
LABEL(KEY_3),
LABEL(KEY_4),
LABEL(KEY_5),
LABEL(KEY_6),
LABEL(KEY_7),
LABEL(KEY_8),
LABEL(KEY_9),
LABEL(KEY_0),
LABEL(KEY_MINUS),
LABEL(KEY_EQUAL),
LABEL(KEY_BACKSPACE),
...
I have no experience in C, and don't know what he means. So my question is: how do I do this?
I have succesfully compiled other JNI libs, using NDK v9 and cygwin, so there should not be a problem with my settings and enviroment.
I had the same issue and imported my own input.h version containing all the missing declarations.
You can do same thing and replace your input.h (you can search for input.h with those undefine identifiers in linux kernel sources), but easier way is to remove lines containing undefined identifiers from EventInjector.h. Just comment all lines that highlighted red in eclipse, and it should work.

error build cocos2dx android

I build cocos2d-x android project on windows 7.
$. / Build_native.sh - run, and the process falls on
Compile++ thumb : cocos2dx_static <= CCFileUtilsAndroid.cpp
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp: In member function 'virtual bool cocos2d::CCFileUtilsAndroid::isFileExist(const string&)':
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:88:9: error: 'FILE' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:88:15: error: 'fp' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:88:50: error: 'fopen' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:92:22: error: 'fclose' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp: In member function 'virtual unsigned char* cocos2d::CCFileUtilsAndroid::getFileData(const char*, const char*, long unsigned int*)':
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:133:13: error: 'FILE' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:133:19: error: 'fp' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:133:50: error: 'fopen' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:137:32: error: 'fseek' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:138:28: error: 'ftell' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:141:62: error: 'fread' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:142:22: error: 'fclose' was not declared in this scope
/cygdrive/d/work/Android/android-ndk-r8-crystax-1/build/core/build-binary.mk:320: recipe for target `obj/local/armeabi/objs/cocos2dx_static/platform/android/CCFileUtilsAndroid.o' failed
ScreenShot : http://joxi.ru/wy6OUdg5CbBkfuw7mZ4
How to fix it to build the project on?
Seems the Cocos2d-x code is not including the cstdio header where those things are declared. To fix this, edit the CCFileUtilsAndroid.cpp file and add the line
#include <cstdio>
up there at the top with the other includes. Now all those f* functions and FILE should be found.
have you solved this problem? Arleryd's solution worked for me, and the later error you post could be solved by this:
import the C:\cocos2d-x-2.2.0\cocos2dx\platform\android to eclipse, then done. see this:
http://www.cocos2d-x.org/wiki/How_to_set_up_the_android_cocos2d-x_development_environment_on_Windows_7

Errors when trying to interface Android with Arduino

I'm currently working on a project trying to get my Samsung Galaxy S2 to interface with the Arduino Mega ADK for Android and I'm getting a bunch of errors.
I've followed directions given here: http://stream.tellart.com/controlling-arduino-with-android/ to the letter. And I've tried running their examples
Specifically the "TapOn" Example (which should allow me to control an LED connected to Arduino from my Android). But each time I run it I get errors on both the processing code for the Android and the arduino code.
Arduino Errors:
AndriodAccessory has not been declaired
AndroidAccessory.cpp:38: error: 'AndroidAccessory' has not been declared
AndroidAccessory.cpp:43: error: ISO C++ forbids declaration of 'AndroidAccessory' with no type
AndroidAccessory.cpp: In function 'int AndroidAccessory(const char*, const char*, const char*, const char*, const char*, const char*)':
AndroidAccessory.cpp:43: error: only constructors take base initializers
AndroidAccessory.cpp: At global scope:
AndroidAccessory.cpp:54: error: 'AndroidAccessory' is not a class or namespace
AndroidAccessory.cpp: In function 'void powerOn()':
AndroidAccessory.cpp:56: error: 'max' was not declared in this scope
AndroidAccessory.cpp:57: error: 'delay' was not declared in this scope
AndroidAccessory.cpp: At global scope:
AndroidAccessory.cpp:60: error: 'AndroidAccessory' is not a class or namespace
AndroidAccessory.cpp:60: error: 'byte' was not declared in this scope
AndroidAccessory.cpp:61: error: expected ',' or ';' before '{' token
AndroidAccessory.cpp:71: error: 'AndroidAccessory' is not a class or namespace
AndroidAccessory.cpp:71: error: variable or field 'sendString' declared void
AndroidAccessory.cpp:71: error: 'byte' was not declared in this scope
AndroidAccessory.cpp:71: error: expected primary-expression before 'int'
AndroidAccessory.cpp:71: error: expected primary-expression before 'const'
AndroidAccessory.cpp:82: error: 'AndroidAccessory' is not a class or namespace
AndroidAccessory.cpp:82: error: 'byte' was not declared in this scope
AndroidAccessory.cpp:83: error: expected ',' or ';' before '{' token
Android/Processing Errors:
Error from inside Android tools
API<=15: Adding annotations.jar to the classpath.
Merging AndroidManifest files into one.
Manifest merger disabled. Using project manifest only.
No AIDL files to compile.
No RenderScript files to compile.
Generating resource IDs...
Generating BuildConfig class.
BUILD FAILED
C:\Users\Nate\Desktop\AndriodSDK\tools\ant\build.xml:705: The following error occurred while executing this line:
C:\Users\Nate\Desktop\AndriodSDK\tools\ant\build.xml:718: Compile failed; see the compiler error output for details.
I don't understand whats wrong and why I'm getting these errors when I haven't changed any of the code from the samples. Also I can write programs for the arduino and android independently of each other, and they work fine... I only get the errors when I want the two to communicate with each-other.
Looks like your code has no library to work with. For me that meant roaming the internet till I found the correct libraries. I would try the following:
Make sure you have the latest Arduino IDE
Download the libraries, probably this.
Although if you want just try the step by step here.

Compiling ICU for Android: error: 'ICU_Utility' has not been declared

While compiling ICU for android, the following error is encountered:
/home/tim/icu49/icu/source/i18n/strmatch.cpp: In member function 'virtual icu_49::UnicodeString& icu_49::StringMatcher::toPattern(icu_49::UnicodeString&, UBool) const':
/home/tim/icu49/icu/source/i18n/strmatch.cpp:166: error: 'ICU_Utility' has not been declared
/home/tim/icu49/icu/source/i18n/strmatch.cpp:168: error: 'ICU_Utility' has not been declared
/home/tim/icu49/icu/source/i18n/strmatch.cpp:176: error: 'ICU_Utility' has not been declared
/home/tim/icu49/icu/source/i18n/strmatch.cpp: In member function 'virtual icu_49::UnicodeString& icu_49::StringMatcher::toReplacerPattern(icu_49::UnicodeString&, UBool) const':
/home/tim/icu49/icu/source/i18n/strmatch.cpp:243: error: 'ICU_Utility' has not been declared
make[1]: *** [strmatch.ao] Error 1
make[1]: Leaving directory `/home/tim/icu49/icu-android/i18n'
make: *** [all-recursive] Error 2
Update. As a hack, this can be solved with -DUCONFIG_NO_TRANSLITERATION (basically ignores the offending block). Doing this gets you past 'strmatch.cpp', but the error re-appears in dbgutil.cpp:143 and 145. Fixable using -DUCONFIG_NO_FORMATTING (losing another feature...) (Next issue: In function icu_49::IcuToolErrorCode::~IcuToolErrorCode()':
toolutil.cpp:(.text+0x400): undefined reference to__cxa_end_cleanup')
Update2. This one is very strange. I undid my configuration changes. In i18n/strmatch.cpp, "util.h" is included. But it seems that it is never called which is why ICU_Utility is not defined. ("util.h" is in icu/source/common). Interestingly, if you use #include "../common/util.h" instead of #include "util.h" it works.
Of course, this now makes sense, because
tim#N01:~/icu49$ find android-ndk-r7b/ -name util.h
android-ndk-r7b/platforms/android-4/arch-x86/usr/include/util.h
android-ndk-r7b/platforms/android-4/arch-arm/usr/include/util.h
android-ndk-r7b/platforms/android-8/arch-x86/usr/include/util.h
android-ndk-r7b/platforms/android-8/arch-arm/usr/include/util.h
android-ndk-r7b/platforms/android-14/arch-x86/usr/include/util.h
android-ndk-r7b/platforms/android-14/arch-arm/usr/include/util.h
android-ndk-r7b/platforms/android-3/arch-x86/usr/include/util.h
android-ndk-r7b/platforms/android-3/arch-arm/usr/include/util.h
android-ndk-r7b/platforms/android-5/arch-x86/usr/include/util.h
android-ndk-r7b/platforms/android-5/arch-arm/usr/include/util.h
android-ndk-r7b/platforms/android-9/arch-x86/usr/include/util.h
android-ndk-r7b/platforms/android-9/arch-arm/usr/include/util.h
Renaming the android-X version from util.h to _util.h provides quick resolution to this issue.

Categories

Resources