can't find the head file when compile rapidxml in ndk - android

i want to parse xml by rapidxml(on android devices, NDK).
but when i include the rapidxml.hpp in my cpp file, and compile it.
the compilor shows me that "jni/rapidxml.hpp:11:47: fatal error: cstdlib: No such file or directory". what's wrong with it?
the code and compile result followed.
source code:
#include "rapidxml_utils.hpp"
void test(){}
compile result:
jni/rapidxml.hpp:11:47: fatal error: cstdlib: No such file or directory
compilation terminated.
make: * [obj/local/armeabi/objs/rapidxml/RapidXml.cpp,rapidxml.o] Error 1

You should also include the header file in your Android.mk using LOCAL_C_INCLUDES in your module.

Related

Compiling stressapptest on NDK for Android

I am currently working on trying to compile the stressapptest (link: https://github.com/stressapptest/stressapptest) using the NDK environment, and for some reason, I'm having a hard time. These are the steps that I have taken:
Clone the repository onto my computer
Added a jni folder and moved all the files into it
Created an Application.mk file
Opened PowerShell from the location of my jni folder and execute ndk-build. This is the error I'm getting:
PS C:\Users\...\Desktop\stressapptest-master\stressapptest-master> ndk-build
Android NDK: APP_PLATFORM not set. Defaulting to minimum supported version android-16.
[arm64-v8a] Compile++ : stressapptest <= main.cc
In file included from jni/src/main.cc:17:
jni/src/sattypes.h:25:10: fatal error: 'algorithm' file not found
#include <algorithm>
^~~~~~~~~~~
1 error generated.
make: *** [obj/local/arm64-v8a/objs/stressapptest/src/main.o] Error 1
Is there anything else that I need in order to compile this to run on an Android system?
Set APP_STL to c++_shared in your Application.mk. ndk-build does not use any STL by default.

Cross Compiling KConfig is not working

I'm trying to compile kconfig, which supposedly works on android, for android but am faced with the following
In file included from /home/dashed/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_algo.h:59:0,
from /home/dashed/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/algorithm:62,
from /home/dashed/android-qt/include/QtCore/qglobal.h:109,
from /home/dashed/android-qt/include/QtCore/QtGlobal:1,
from /home/dashed/Documents/kconfig/src/core/kconfigbase.h:29,
from /home/dashed/Documents/kconfig/src/core/kconfig.h:27,
from /home/dashed/Documents/kconfig/src/core/kconfig.cpp:23:
/home/dashed/android-ndk-r10e/sources/cxx-stl/gnu-
libstdc++/4.9/include/cstdlib:72:20: fatal error: stdlib.h: No such file or directory
#include <stdlib.h>
^
I generated the makefile with :
cmake -DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake -DECM_ADDITIONAL_FIND_ROOT_PATH=/home/dashed/android-qt -DCMAKE_INSTALL_PREFIX=/home/dashed/android-kf5 ..
what can I do to compile it successfully ?
I sorta 'solved' this by updating my ndk. I was using r10e to compile qt but using r17b is successful.

howto use the libcurl by ndk standalone tool chainon on android

now, i have a question: first of all i already get the ndk standalone tool chain ---arm-linux-androideabi-g++ sucessful; now i have to write a commandline c++ program which will use libcurl to do http requests, i can successful compile it on my mac( which has the libcurl default? ) use g++, but when i use the arm-linux-androideabi-g++ to compile it, it produce following error:
arm-linux-androideabi-g++ -std=c++11 -lcurl upload.cpp -o upload
upload.cpp:12:23: fatal error: curl/curl.h: no such file or directory
compilation terminated
i have a libcurl(include files and .a lib file) which can used in android, so howto configure the arm-linux-androideabi-g++ so that it can compile it successfully? thanks advance
I guess you include your header like
#include <curl/curl.h>
if you do that, arm-linux-androideabi-g++ searches header file in some specific location. and if arm-linux-androideabi-g++ does not point same directory with g++, headers can not be found. try to copy just header files of curl to your project, jni/curl folder, and use " instead of <
#include "curl/curl.h"
if you have right .a file, functions in header files will be pointed to lib file successfully.

Error after building a testcpp Eclipse Project

I am trying to build and run a test project for android following this guide :
"http://www.cocos2d-x.org/wiki/Setting_up_Android_Development_Environment_on_Mac_OSX#Get-the-NDK"
The specific problem is after building the Test demo in eclipse which is called "TestCpp"
which has another project linked to it "libcocos2dx" i get an error stating:
make: *** [obj/local/armeabi/objs/cocos_extension_static/CocoStudio/Reader/WidgetReader/LabelReader/LabelReader.o] Error 1
This is what the console displayed through the build process:
**** Build of configuration Default for project TestCpp ****
bash /Users/mohammadbaroudi/Downloads/cocos2d-x-2.2.5/samples/Cpp/TestCpp/proj.android/build_native.sh
NDK_ROOT = /Users/mohammadbaroudi/Downloads/android-ndk-r10
COCOS2DX_ROOT = /Users/mohammadbaroudi/Downloads/cocos2d-x-2.2.5/samples/Cpp/TestCpp/proj.android/../../../..
APP_ROOT = /Users/mohammadbaroudi/Downloads/cocos2d-x-2.2.5/samples/Cpp/TestCpp/proj.android/..
APP_ANDROID_ROOT = /Users/mohammadbaroudi/Downloads/cocos2d-x-2.2.5/samples/Cpp/TestCpp/proj.android
Using prebuilt externals
Android NDK: WARNING:/Users/mohammadbaroudi/Downloads/cocos2d-x-2.2.5/samples/Cpp/TestCpp/proj.android/../../../../cocos2dx/Android.mk:cocos2dx_static: LOCAL_LDLIBS is always ignored for static libraries
make: Entering directory /Users/mohammadbaroudi/Downloads/cocos2d-x-2.2.5/samples/Cpp/TestCpp/proj.android'
[armeabi] Compile++ thumb: cocos_extension_static <= LabelReader.cpp
/Users/mohammadbaroudi/Downloads/cocos2d-x-2.2.5/samples/Cpp/TestCpp/proj.android/../../../../extensions/CocoStudio/Reader/WidgetReader/LabelReader/LabelReader.cpp: In member function 'virtual void cocos2d::extension::LabelReader::setPropsFromJsonDictionary(cocos2d::ui::Widget*, const Value&)':
/Users/mohammadbaroudi/Downloads/cocos2d-x-2.2.5/samples/Cpp/TestCpp/proj.android/../../../../extensions/CocoStudio/Reader/WidgetReader/LabelReader/LabelReader.cpp:54:9: error: 'transform' is not a member of 'std'
std::transform(file_extension.begin(),file_extension.end(), file_extension.begin(), (int(*)(int))toupper);
^
make: *** [obj/local/armeabi/objs/cocos_extension_static/CocoStudio/Reader/WidgetReader/LabelReader/LabelReader.o] Error 1
make: Leaving directory/Users/mohammadbaroudi/Downloads/cocos2d-x-2.2.5/samples/Cpp/TestCpp/proj.android'
**** Build Finished ****
Now I checked the file path and it pointed to a non-existing obj file "LabelReader.o", the strange thing is that in the "/WidgetReader" folder "mentioned in the error above", there are multiple reader folders e.g:"ButtonReader,CheckBoxReader,etc" all with accompanying ".o" & ".o.d" files with the same names except for the LabelReader folder which is empty.
I tried to exclude the "LabelReader.o" file from the build process through right clicking on the file in eclipse and excluding it, but the same error occurred and I tried to right click on the error in the problems tab and hit "fix" which notified me that it cant fix it.The last thing that came to mind was excluding the "LabelReader.o" file from compilation through modifying the makefile itself, where its discussed here:
Makefile. How to exclude one particular file from compilation?
But there seemed to be multiple methods of doing so, and still i am not sure i completely understand whats wrong other than there is a missing file thats being complied but can't be built.I am sorry if this question is too big and it also is my first question here so excuse me if i wrote a lot.
add this line in file where error occurred
#include <algorithm>

Android NDK doesn't support header files?

This page has instuctions for compiling iwlist and other commands for Android:
https://code.google.com/p/haggle/wiki/WirelessTools
Unfortunately I'm getting the same type of error as the commenter on that page:
Android NDK: WARNING: Unsupported source file extensions in /home/simon/Android-SDK/wireless_tools.29/Android.mk for module iwlist Android NDK: iwlib.h
When I remove the iwlib.h from the LOCAL_SRC_FILES of the Android.mk, it doesn't show that warning, but it still fails with the same error:
./iwlist.c:633:7: error: 'IW_EV_LCP_PK2_LEN' undeclared (first use in this function)
This is undeclared because it is in the iwlib.h file it's warning about.
So why does the Android NDK not recognize header .h files?
To build the libraries, you unpacked the gz file, and ran make, didn't you? Or you simply renamed wireless.22.h? Anyways, before you runndk-build, you have a wireless.h file in the package directory. Add the following two lines to the end of this file:
#undef IW_EV_LCP_PK_LEN
#undef IW_EV_POINT_PK_LEN
And remove the iwlib.h from the LOCAL_SRC_FILES of the Android.mk. #Gabe is right, header files should not be compiled separately. In iwlist.c you will find line 14:
#include "iwlib.h"
You normally don't compile header files. You include them in a .c or .cpp file that you do compile. But you wouldn't pass them into the compiler as a source file.

Categories

Resources