Android bitmap.h is not found for native code compile - android

I am trying to compile code using the Android NDK. I have previously used this code fine, but changed one thing in it and now it will not compile. The error that shows up is:
"Compile++ thumb : filters <= filters.cpp
C:/Android/my-app//jni/filters.cpp:4:28: fatal error: android
/bitmap.h: No such file or directory
compilation terminated.
make: *** [C:/Android/my-app//obj/local/armeabi/objs/filters/
filters.o] Error 1
My bitmap.h file is defined in the library as:
#include <android/bitmap.h>
I know that bitmap.h is only there after a target-skd build of 8 or higher, and mine is a target of 10 and min of 8. Any suggestions? This is driving me crazy and used to work!Thanks for any help you can provide.
Edit: Here is my Android.mk file also
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := filters
LOCAL_SRC_FILES := filters.cpp
LOCAL_LDLIBS := -lm -llog -ljnigraphics
include $(BUILD_SHARED_LIBRARY)

Got it to work. I was using SDK tools revision 20, and platform-tools revision 12. In order to get it to compile, I had to specify the APP_PLATFORM in the command line (apparently these revisions default to something else).
Just ran:
ndk-build APP_PLATFORM=android-8
and it built!

Insert APP_PLATFORM=android-8 into file Application.mk

Well, the answer bellow helped me also.
I tried setting the APP_PLATFORM variabile to android-10 from Application.mk (as I expected this option should also be where the APP_ABI is), but that didn't help.
Pretty non-intuitive, but whatever works, right..?

Related

Crystax NDK linker error

I'm trying to get working Crystax NDK example and have the following error (I've made up PATH/TO/MY/CRYSTAXNDK/ of course):
$ ndk-build APP_ABI=armeabi-v7a
[armeabi-v7a] Executable : test-boost
PATH/TO/MY/CRYSTAXNDK/crystax-ndk-10.3.1/sources/boost/1.59.0/include/boost/archive/detail/oserializer.hpp:88: error: undefined reference to 'boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
Actually, this example is a bit outdated and I've already solved this error:
Android NDK: ERROR:PATH/TO/MY/CRYSTAXNDK/crystax-ndk-10.3.1/sources/boost/1.59.0/Android.mk:boost_atomic_static: LOCAL_SRC_FILES points to a missing file
Android NDK: Check that PATH/TO/MY/CRYSTAXNDK/crystax-ndk-10.3.1/sources/boost/1.59.0/libs/armeabi-v7a/gnu-/libboost_atomic.a exists or that its path is correct
by adding NDK_TOOLCHAIN_VERSION=4.9 into Android.mk.
I've also replaced $(call import-module,boost/1.57.0) with $(call import-module,boost/1.59.0) to call actual version of Boost library.
So, my Android.mk looks as following:
# Android.mk
LOCAL_PATH := $(call my-dir)
NDK_TOOLCHAIN_VERSION = 4.9
include $(CLEAR_VARS)
LOCAL_MODULE := test-boost
LOCAL_SRC_FILES := test.cpp gps.cpp
LOCAL_STATIC_LIBRARIES := boost_serialization_static
include $(BUILD_EXECUTABLE)
$(call import-module,boost/1.59.0)
My crystax-ndk directory is in a system path. I understand that the cause of my problem is that NDK linker is unable to find proper Boost libraries. But I don't know how to configure it in such a way that it will automatically choose libraries depending on the target architecture.
Please help me to figure out the configuration of the linker!
Thanks.
This is bug. Shortly speaking, libboost_serialization.so was built with GNU libstdc++ v5, but when you call ndk-build, it link final binary with GNU libstdc++ v4.9, which is binary incompatible with GNU libstdc++ v5 (specifically, std::basic_string; if interested, please look here for details).
This is fixed by a7c363377 and will be included to the next bug-fix release (10.3.2). In the meantime, you can apply that patch manually on your crystax-ndk-10.3.1 file tree to solve the problem.
I ran into the same problem following the CrytaX blog tutorial. I fixed it by adding the following
# Application.mk
APP_ABI := all
NDK_TOOLCHAIN_VERSION := 5
APP_PLATFORM := android-19
The 2nd line fixed the ndk-build Boost gcc lib path error. The 3rd line fixed the "only position independent executables" problem when invoking the executable.

Compiling PugiXML with Android NDK

I'm trying to compile the PugiXML library with Android NDK; it says on the website that this is possible, but the download doesn't contain an android makefile and I haven't used NDK much before (the docs don't help!)
I'm currently getting the error:
/pugiconfig.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
I was originally getting an error because NDK couldn't find #include <iterator> and I'm not sure I've correctly resolved this. I tried following this stackoverflow Q/A and ended up with the error shown above.
My current Android.mk looks like this:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := webface
LOCAL_CPP_EXTENSION := .hpp .cpp
LOCAL_SRC_FILES := ../pugiconfig.hpp ../pugixml.hpp ../pugixml.cpp
include $(BUILD_SHARED_LIBRARY)
and my current Application.mk looks like this:
APP_ABI := all
APP_STL := stlport_shared
I'd suggest removing everything but pugixml.cpp from LOCAL_SRC_FILES.
Also, note that if you have issues with you can just compile with PUGIXML_NO_STL (by adding -DPUGIXML_NO_STL to CXXFLAGS).

fatal error: fitz.h: No such file or directory in muPDF library

I m trying to compile the muPDF lib in eclipse for android app since 3 days without any success
I downloaded and configured the android-ndk, cygwin
Im getting this still
15:25:36 **** Build of configuration Debug for project ChoosePDFActivity ****
"E:\\android-ndk\\android-ndk-r9d\\ndk-build.cmd" all
Android NDK: WARNING:E:/Workspace_SIL/ChoosePDFActivity//jni/Android.mk:mupdfcore: LOCAL_LDLIBS is always ignored for static libraries
Android NDK: WARNING:E:/Workspace_SIL/ChoosePDFActivity//jni/Android.mk:mupdfcore: LOCAL_LDLIBS is always ignored for static libraries
[armeabi] Compile thumb : mupdf <= mupdf.c
E:/Workspace_SIL/ChoosePDFActivity//jni/mupdf.c:10:18: fatal error: fitz.h: No such file or directory
compilation terminated.
make.exe: *** [E:/Workspace_SIL/ChoosePDFActivity//obj/local/armeabi/objs-debug/mupdf/mupdf.o] Error 1
15:25:36 Build Finished (took 489ms)
jni/mupdf.c:10:18: fatal error: fitz.h: No such file or directory
where I can get this God Damn fitz.h and other header files
see this happens in my eclipse
included the following paths for my header files
setup android Ndk path like this
Update1
Here is my Android.mk file
LOCAL_PATH := $(call my-dir)
TOP_LOCAL_PATH := $(LOCAL_PATH)
MUPDF_ROOT := ..
include $(TOP_LOCAL_PATH)/Core.mk
include $(TOP_LOCAL_PATH)/ThirdParty.mk
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := \
$(MUPDF_ROOT)/draw \
$(MUPDF_ROOT)/fitz \
$(MUPDF_ROOT)/pdf
LOCAL_CFLAGS :=
LOCAL_MODULE := mupdf
LOCAL_SRC_FILES := mupdf.c
LOCAL_STATIC_LIBRARIES := mupdfcore mupdfthirdparty
LOCAL_LDLIBS := -lm -llog -ljnigraphics
include $(BUILD_SHARED_LIBRARY)
Check the jni folder and find the Anroid.mk. Open it and check whether you added the LOCAL_SRC_FILES and LOCAL_C_INCLUDES. The LOCAL_C_INCLUDES should be your .h files' path. The LOCAL_SRC_FILES should be every .c or .cpp file's path.
cygwin no t install properly, follow following links and sure your installations correctly than run some commands according to below links.
For window 7
For window XP
You're also using an old version of the MuPDF source code.
1) Use the latest version (1.5 currently, or better, work from git).
2) Don't build it using eclipse, use the supported ndk/sdk based build as described in platform/android/ReadMe.txt. If you want to use eclipse, do so only after you have managed to build it in the supported way.
3) Do not skip step 10 of the instructions. Seriously, why does everyone try to skip step 10?
4) If you get stuck, come talk to us in the #ghostscript irc channel on freenode. A weblink can be found to this on mupdf.com

Android NDK won't build library because Bitmap.h is missing?

I'm using the Android NDK to build a library. I had everything working well, but then I needed to change a package name which is referenced in the library. I tried to build the library again once I made the change, by calling ndk-build in its folder, but this is the only output I get and it does not seem to be fully building:
C:\my-app\jni>ndk-build -B
"Compile++ thumb : filters <= filters.cpp
C:/a-fa-outsidelands//jni/filters.cpp:4:28: fatal error: android/bitmap.h: No such file or directory
compilation terminated.
This then leads to an unsatisfied link error when I try to run the application. I'll post my .mk file, but I don't think that should matter because my previous library was working with this .mk file. I'm doing the rebuild (the -B parameter) because it is over a previous build. Any suggestions? Here's my .mk file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := filters
LOCAL_SRC_FILES := filters.cpp
LOCAL_LDLIBS := -lm -llog -ljnigraphics
include $(BUILD_SHARED_LIBRARY)
Thanks for the help.
What's the android:targetSdkVersion in the app's manifest? IIRC, bitmap.h was not introduced until SDK v8.
EDIT: Was the last successful build on the same machine, with the same NDK version? Does the #include line use <android/bitmap.h> as opposed to "android/bitmap.h"?
EDIT2: Did the targetSdkVersion change since the last build? I found a funny thing: there's no android-10 under android-ndk-xx\platforms. Try creating a blank android-10 folder under android-ndk-xx\platforms and copying the contents of android-9 there. I'm honestly not sure what else to check.
I got the same problem. Then I found this answer.
Android bitmap.h is not found for native code compile
Just ran:
ndk-build APP_PLATFORM=android-8

How to build NDK Library over a previous build

I'm using the Android NDK to build a library. I had everything working well, but then I needed to change a package name which is referenced in the library. I tried to build the library again once I made the change, by calling ndk-build in its folder, but this is the only output I get and it does not seem to be fully building:
C:\my-app\jni>ndk-build
Install : libfilters.so => libs/armeabi/libfilters.so
This then leads to an unsatisfied link error when I try to run the application. I'll post my .mk file, but I don't think that should matter because my previous library was working with this .mk file. My guess is that there is a problem with me trying to build this one over the previous build. Any suggestions? Here's my .mk file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := filters
LOCAL_SRC_FILES := filters.cpp
LOCAL_LDLIBS := -lm -llog -ljnigraphics
include $(BUILD_SHARED_LIBRARY)
Thanks for the help.
Edit: Once I do the rebuild as indicated, then I get the following error:
"Compile++ thumb : filters <= filters.cpp
C:/a-fa-outsidelands//jni/filters.cpp:4:28: fatal error: android/bitmap.h: No such file or directory
compilation terminated.
ndk-build -B
forces a full rebuild.

Categories

Resources