stlport related unresolved external - android

I'm using NDK build & seeing this weird linker error:
./external/stlport/stlport/stl/_fstream.c:139: error: undefined reference to 'std::_Filebuf_base::_M_seek(long long, int)'
./external/stlport/stlport/stl/_fstream.c:391: error: undefined reference to 'std::_Filebuf_base::_M_seek(long long, int)'
./external/stlport/stlport/stl/_fstream.c:120: error: undefined reference to 'std::_Filebuf_base::_M_unmap(void*, long long)'
./external/stlport/stlport/stl/_fstream.c:320: error: undefined reference to 'std::_Filebuf_base::_M_seek(long long, int)'
./external/stlport/stlport/stl/_fstream.c:336: error: undefined reference to 'std::_Filebuf_base::_M_seek(long long, int)'
./external/stlport/stlport/stl/_fstream.c:120: error: undefined reference to 'std::_Filebuf_base::_M_unmap(void*, long long)'
./external/stlport/stlport/stl/_fstream.c:120: error: undefined reference to 'std::_Filebuf_base::_M_unmap(void*, long long)'
./external/stlport/stlport/stl/_fstream.c:120: error: undefined reference to 'std::_Filebuf_base::_M_unmap(void*, long long)'
collect2: error: ld returned 1 exit status
I got the objdump output of fstream.o & I do see this _M_seek() function. Any ideas why it's still not able to find it. Here are some entries in my Android.mk:
LOCAL_C_INCLUDES += $(TOP)/external/stlport/stlport \
$(TOP)/bionic/libstdc++/include \
$(TOP)/bionic \
LOCAL_CFLAGS += -std=gnu++11 -std=c++11
LOCAL_CPPFLAGS := -std=gnu++11 -std=c++11
LOCAL_SHARED_LIBRARIES := libcutils liblog libutils libstlport
Am I missing anything?

See if you defined _LARGEFILE_SOURCE in your Android.mk file. If it had been defined, remove it can solve the problem.

Related

Errors while using sstream in android

I'm writing an executable for android, and in it I use std::stringstream.
Therefore, I include the library <sstream>, and when I compile my code, I get the following linker errors:
external/libcxx/include/streambuf:220: error: undefined reference to 'std::__1::locale::~locale()'
external/libcxx/include/ios:661: error: undefined reference to 'std::__1::ios_base::~ios_base()'
external/libcxx/include/ios:524: error: undefined reference to 'std::__1::ios_base::clear(unsigned int)'
external/libcxx/include/ostream:260: error: undefined reference to 'std::uncaught_exception()'
external/libcxx/include/ios:524: error: undefined reference to 'std::__1::ios_base::clear(unsigned int)'
external/libcxx/include/ios:524: error: undefined reference to 'std::__1::ios_base::clear(unsigned int)'
external/libcxx/include/istream:291: error: undefined reference to 'std::__1::ios_base::getloc() const'
external/libcxx/include/__locale:186: error: undefined reference to 'std::__1::locale::use_facet(std::__1::locale::id&) const'
external/libcxx/include/istream:291: error: undefined reference to 'std::__1::locale::~locale()'
external/libcxx/include/ios:524: error: undefined reference to 'std::__1::ios_base::clear(unsigned int)'
external/libcxx/include/istream:304: error: undefined reference to 'std::__1::ctype<char>::id'
external/libcxx/include/ios:668: error: undefined reference to 'std::__1::ios_base::init(void*)'
external/libcxx/include/streambuf:370: error: undefined reference to 'std::__1::locale::locale()'
collect2: error: ld returned 1 exit status
I don't know what I did wrong.. all the other STL classes worked fine until now.
Here is the project's Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS += -std=c++11 -w
LOCAL_MODULE := my_module
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/includes
LOCAL_MODULE_TAGS := eng debug optional
LOCAL_LDFLAGS := -static
LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_SRC_FILES += \
file_a.c \
file_b.c \
file_c.c
LOCAL_SRC_FILES += \
file_1.cpp \
file_2.cpp \
file_3.cpp
LOCAL_STATIC_LIBRARIES := \
liblog \
libc
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN)
include $(BUILD_EXECUTABLE)
Am I missing something?

Compile JNI library that includes OpenCV headers

Hy!
I have an Android project with a cpp file that needs to be compiled. This file is including some headers of the OpenCV library. The OpenCV source files are under jni/include/opencv2 folder as you can see in Android.mk file. When I try to compile with the ndk-build the file the compiler gives the following error:
"undefined reference to"
It seems that is a "error: undefined reference to" problem to all this files.
The Android.mk file have the following content:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
OPENCV_PACKAGE_DIR := $(LOCAL_PATH)/include
LOCAL_MODULE := iqindex
LOCAL_C_INCLUDES := \
$(LOCAL_PATH) \
$(OPENCV_PACKAGE_DIR)
LOCAL_SRC_FILES := \
main.cpp
LOCAL_SHARED_LIBRARIES := iqindex
LOCAL_LDLIBS := -llog -lz
include $(BUILD_SHARED_LIBRARY)
I do not have enough experience with jni/ndk stuff and my questions are:
To compile a .cpp file that needs another header files is enough to compile it with ndk-build command and it will be all done ?
What is wrong in my attempt to compile it ? And what is wrong in Android.mk ?
EDIT: The console error is the following:
C:\MyName\My Project App>ndk-build
C:/MyName/android-ndk-r8e/build/core/add-application.mk:128: Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml
SharedLibrary : libiqindex.so
C:/MyName/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/iqindex/main.o:(.ARM.extab.text.unlikely._ZL6jthrowP7_JNIEnv+0x2c): error: undefined reference to 'typeinfo for cv::Exception'
C:/MyName/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/iqindex/main.o: in function cv::Mat::Mat(cv::Mat const&):jni/include/opencv2/core/mat.hpp:125: error: undefined reference to 'cv::Mat::copySize(cv::Mat const&)'
C:/MyName/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/iqindex/main.o: in function cv::Mat::release():jni/include/opencv2/core/mat.hpp:364: error: undefined reference to 'cv::Mat::deallocate()'
C:/MyName/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/iqindex/main.o: in function cv::Mat::~Mat():jni/include/opencv2/core/mat.hpp:278: error: undefined reference to 'cv::fastFree(void*)'
C:/MyName/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/iqindex/main.o: in function Java_project_name_zxing_Mat_submat_1n:jni/include/opencv2/core/mat.hpp:376: error: undefined reference to 'cv::Mat::Mat(cv::Mat const&, cv::Rect_<int> const&)'
C:/MyName/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/iqindex/main.o: in function Java_project_name_zxing_Mat_resize_1n:jni/main.cpp:111: error: undefined reference to 'cv::_InputArray::_InputArray(cv::Mat const&)'
C:/MyName/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/iqindex/main.o: in function Java_project_name_zxing_Mat_resize_1n:jni/main.cpp:111: error: undefined reference to 'cv::_OutputArray::_OutputArray(cv::Mat&)'
C:/MyName/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/iqindex/main.o: in function Java_project_name_zxing_Mat_resize_1n:jni/main.cpp:111: error: undefined reference to 'cv::resize(cv::_InputArray const&, cv::_OutputArray const&, cv::Size_<int>, double, double, int)'
C:/MyName/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/iqindex/main.o: in function Java_project_name_zxing_Utils_rotateData:jni/main.cpp:124: error: undefined reference to'cv::_InputArray::_InputArray(cv::Mat const&)'
C:/MyName/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/iqindex/main.o: in function Java_project_name_zxing_Utils_rotateData:jni/main.cpp:124: error: undefined reference to'cv::_OutputArray::_OutputArray(cv::Mat&)'
C:/MyName/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/iqindex/main.o: in function Java_project_name_zxing_Utils_rotateData:jni/main.cpp:124: error: undefined reference to'cv::flip(cv::_InputArray const&, cv::_OutputArray const&, int)'
C:/MyName/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/iqindex/main.o: in function Java_project_name_zxing_Utils_rotateData:jni/main.cpp:125: error: undefined reference to'cv::Mat::t() const'
C:/MyName/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/iqindex/main.o: in function Java_project_name_zxing_IQLocal_nativeCreate:jni/main.cpp:139: error: undefined reference to 'get_instance()'
C:/MyName/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/iqindex/main.o: in function Java_project_name_zxing_IQLocal_load:jni/main.cpp:156: error: undefined reference to 'IQIndex::load(std::string, std::string)'
C:/MyName/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/iqindex/main.o: in function Java_project_name_zxing_IQLocal_match:jni/main.cpp:171: error: undefined reference to 'IQIndex::match(cv::Mat&)'
C:/MyName/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/iqindex/main.o: in function Java_project_name_zxing_IQLocal_train:jni/main.cpp:182: error: undefined reference to 'IQIndex::train()'
C:/MyName/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/iqindex/main.o: in function Java_project_name_zxing_IQLocal_compute:jni/main.cpp:198: error: undefined reference to 'IQIndex::compute(cv::Mat const&, char const*, char const*)'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi-v7a/libiqindex.so] Error 1
SECOND EDIT: Now the Android.mk looks like this:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# OpenCV
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
include C:/Emil/downloads/OpenCV-2.4.6-android-sdk-r2/OpenCV-2.4.6-android-sdk/sdk /native/jni/OpenCV.mk
LOCAL_MODULE := iqindex
LOCAL_SRC_FILES := \
main.cpp
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/iqindex.h
LOCAL_LDLIBS := -llog -lz
include $(BUILD_SHARED_LIBRARY)
I suppose that you forgot to add OpenCV libriries to your project. So linker can't find OpenCV related functions.
From OpenCV documentation:
If your application project doesn’t have a JNI part, just copy the
corresponding OpenCV native libs from
/sdk/native/libs/ to your
project directory to folder libs/.
In case of the application project with a JNI part, instead of manual
libraries copying you need to modify your Android.mk file: add the
following two code lines after the "include $(CLEAR_VARS)" and before
"include path_to_OpenCV-2.4.6-android-sdk/sdk/native/jni/OpenCV.mk
OPENCV_CAMERA_MODULES:=on OPENCV_INSTALL_MODULES:=on
So you should have following lines in your Android.mk:
include $(CLEAR_VARS)
# OpenCV
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
include ../../sdk/native/jni/OpenCV.mk
This is late, but in response to :
Now I have another problem: I have in the jni folder a header file named iqindex.h . The cpp file includes it, but now I have "undefined reference to" iqindex.h when I try to build. I tried the LOCAL_C_INCLUDES command in Android.mk which pointed to the header file, but then it doesn't see openCV anymore at compile time. How do I include this header to make the files to compile ?
The problem probably is that you used LOCAL_C_INCLUDES :=/foo/bar
Try LOCAL_C_INCLUDES +=/foo/bar.
You should add the include directory, not overwrite the existing includes.

Issues with undefined reference NDK

Ok I know that this has been brought up. Yet mine does not seem to be addressed.
Before we start let it be known the following:
OS: Win7 (x86)
IDE: Eclipse Juno (4.2)
NDK: r8e
Android API: 17 (Jelly Bean 4.2)
I am trying to get SDL_ttf to fully compile. I am just trying to build this project and get on with things and after much struggling with getting it to recognize that certain files do in fact exist exactly where they say they exists. I am now getting
Updated:
17:06:42 **** Incremental Build of configuration Default for project OmegaDice ****
"C:\\android-ndk-r8e\\ndk-build.cmd" V=1 clean all all
FIND: Parameter format not correct
Clean: SDL2 [armeabi]
Clean: SDL2_ttf [armeabi]
Clean: freetype [armeabi]
Clean: main [armeabi]
Clean: stlport_shared [armeabi]
Clean: stlport_static [armeabi]
del /f/q .\libs\armeabi\libSDL2.so >NUL 2>NUL
Install : libSDL2.so => libs/armeabi/libSDL2.so
copy /b/y ".\obj\local\armeabi\libSDL2.so" ".\libs\armeabi\libSDL2.so" > NUL
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-strip --strip-unneeded ./libs/armeabi/libSDL2.so
"Compile thumb : SDL2_ttf <= SDL_ttf.c
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Ijni/SDL_ttf -Ijni/SDL_ttf/../SDL/include -Ijni/SDL_ttf/../freetype/include -Ijni/SDL_ttf/include -IC:/android-ndk-r8e/sources/cxx-stl/stlport/stlport -IC:/android-ndk-r8e/sources/cxx-stl//gabi++/include -Ijni/SDL_ttf -DANDROID -Os -Wa,--noexecstack -IC:/android-ndk-r8e/platforms/android-14/arch-arm/usr/include -c jni/SDL_ttf/SDL_ttf.c -o ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o
SharedLibrary : libSDL2_ttf.so
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-g++ -Wl,-soname,libSDL2_ttf.so -shared --sysroot=C:/android-ndk-r8e/platforms/android-14/arch-arm ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o ./obj/local/armeabi/libfreetype.a -lgcc ./obj/local/armeabi/libSDL2.so -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -LC:/android-ndk-r8e/platforms/android-14/arch-arm/usr/lib -lz -lc -lm -o ./obj/local/armeabi/libSDL2_ttf.so
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function Find_Glyph:jni/SDL_ttf/SDL_ttf.c:590: error: undefined reference to 'FT_Get_Char_Index'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function Find_Glyph:jni/SDL_ttf/SDL_ttf.c:592: error: undefined reference to 'FT_Load_Glyph'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function Find_Glyph:jni/SDL_ttf/SDL_ttf.c:656: error: undefined reference to 'FT_Outline_Transform'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function Find_Glyph:jni/SDL_ttf/SDL_ttf.c:662: error: undefined reference to 'FT_Get_Glyph'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function Find_Glyph:jni/SDL_ttf/SDL_ttf.c:663: error: undefined reference to 'FT_Stroker_New'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function Find_Glyph:jni/SDL_ttf/SDL_ttf.c:667: error: undefined reference to 'FT_Stroker_Set'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function Find_Glyph:jni/SDL_ttf/SDL_ttf.c:669: error: undefined reference to 'FT_Glyph_Stroke'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function Find_Glyph:jni/SDL_ttf/SDL_ttf.c:671: error: undefined reference to 'FT_Stroker_Done'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function Find_Glyph:jni/SDL_ttf/SDL_ttf.c:673: error: undefined reference to 'FT_Glyph_To_Bitmap'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function Find_Glyph:jni/SDL_ttf/SDL_ttf.c:676: error: undefined reference to 'FT_Done_Glyph'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function Find_Glyph:jni/SDL_ttf/SDL_ttf.c:682: error: undefined reference to 'FT_Render_Glyph'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function Find_Glyph:jni/SDL_ttf/SDL_ttf.c:885: error: undefined reference to 'FT_Done_Glyph'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function TTF_Init:jni/SDL_ttf/SDL_ttf.c:334: error: undefined reference to 'FT_Init_FreeType'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function TTF_CloseFont:jni/SDL_ttf/SDL_ttf.c:915: error: undefined reference to 'FT_Done_Face'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function TTF_OpenFontIndexRW:jni/SDL_ttf/SDL_ttf.c:420: error: undefined reference to 'FT_Open_Face'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function TTF_OpenFontIndexRW:jni/SDL_ttf/SDL_ttf.c:442: error: undefined reference to 'FT_Set_Charmap'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function TTF_OpenFontIndexRW:jni/SDL_ttf/SDL_ttf.c:448: error: undefined reference to 'FT_Set_Char_Size'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function TTF_OpenFontIndexRW:jni/SDL_ttf/SDL_ttf.c:457: error: undefined reference to 'FT_MulFix'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function TTF_OpenFontIndexRW:jni/SDL_ttf/SDL_ttf.c:458: error: undefined reference to 'FT_MulFix'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function TTF_OpenFontIndexRW:jni/SDL_ttf/SDL_ttf.c:460: error: undefined reference to 'FT_MulFix'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function TTF_OpenFontIndexRW:jni/SDL_ttf/SDL_ttf.c:462: error: undefined reference to 'FT_MulFix'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function TTF_OpenFontIndexRW:jni/SDL_ttf/SDL_ttf.c:474: error: undefined reference to 'FT_Set_Pixel_Sizes'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function TTF_GlyphIsProvided:jni/SDL_ttf/SDL_ttf.c:1103: error: undefined reference to 'FT_Get_Char_Index'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function TTF_SizeUTF8:jni/SDL_ttf/SDL_ttf.c:1204: error: undefined reference to 'FT_Get_Kerning'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function TTF_RenderUTF8_Solid:jni/SDL_ttf/SDL_ttf.c:1390: error: undefined reference to 'FT_Get_Kerning'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function TTF_RenderUTF8_Shaded:jni/SDL_ttf/SDL_ttf.c:1568: error: undefined reference to 'FT_Get_Kerning'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function TTF_RenderUTF8_Blended:jni/SDL_ttf/SDL_ttf.c:1732: error: undefined reference to 'FT_Get_Kerning'
C:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/SDL2_ttf/SDL_ttf.o: in function TTF_Quit:jni/SDL_ttf/SDL_ttf.c:2140: error: undefined reference to 'FT_Done_FreeType'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/libSDL2_ttf.so] Error 1
17:07:20 Build Finished (took 37s.757ms)
jni/SDL_ttf/Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := SDL2_ttf
FREETYPE := $(LOCAL_PATH)/freetype
LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/../SDL/include $(LOCAL_PATH)/../freetype/include $(LOCAL_PATH)/include
LOCAL_CFLAGS := -Os
LOCAL_CPP_EXTENSION := .cpp
LOCAL_SRC_FILES := SDL_ttf.c
LOCAL_SHARED_LIBRARIES := SDL2
LOCAL_STATIC_LIBRARIES := freetype
LOCAL_LDLIBS := -lz
include $(BUILD_SHARED_LIBRARY)
So if anyone has any helpful suggestions as to why this is happening or how to fix it would be greatly appreciated.
The problem is this:
FIND: Parameter format not correct
so freetype is not compiled.
You are building in Windows, so the find command being executed is the Windows version, which has a different syntax.
You need to download a find program that has the same syntax of the unix one.
e.g. from here:
http://unxutils.sourceforge.net/
Then you need to force freetype Android.mk to use the new find:
change:
APP_SUBDIRS := $(patsubst $(LOCAL_PATH)/%, %, $(shell find $(LOCAL_PATH)/src -type d))
to
APP_SUBDIRS := $(patsubst $(LOCAL_PATH)/%, %, $(shell PATH_TO_UNIXLIKE_FIND\find $(LOCAL_PATH)/src -type d))
e.g.
APP_SUBDIRS := $(patsubst $(LOCAL_PATH)/%, %, $(shell c:\unixtools\usr\local\wbin\find $(LOCAL_PATH)/src -type d))

cocos2dx eclipse: Various "error: undefined reference to "

I'm tryng to port an iOS game to Android platform with cocos2dx 2.0.4.
The core of the game is written in c++ and we managed to run it on iOS, in fact the game is avaivable on the Apple Store.
I'm using NDK r8d and lastest SDK, but I'm encountering a lot of issues when trying to build.
My application.mk is like this:
APP_STL := stlport_shared
APP_CPPFLAGS := -frtti
NDK_TOOLCHAIN_VERSION=4.7
Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
ifdef STLG
LOCAL_MODULE := stlport_stlg
else
LOCAL_MODULE := stlport
endif
LOCAL_CFLAGS += -D__ANDROID__ \
-isystem $(SYSROOT)/usr/include \
LOCAL_MODULE := game_shared
LOCAL_MODULE_FILENAME := libgame
LOCAL_CPPFLAGS += -fexceptions
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes $(LOCAL_PATH)/../../../../Box2D $(LOCAL_PATH)/../../../../cocos2dx $(LOCAL_PATH)/../../../../
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static cocos_extension_static
include $(BUILD_SHARED_LIBRARY)
$(call import-module,CocosDenshion/android) \
$(call import-module,cocos2dx) \
$(call import-module,extensions)
Here's the console log (only errors displayed):
/Users/arianna/android/android-ndk-r8d/sources/cxx-stl/stlport/stlport/stl/_alloc.h:158: error: undefined reference to 'std::__node_alloc::_M_allocate(unsigned int&)'
make: Leaving directory `/Users/arianna/android/cocos2d-2.0-x-2.0.4/grannnnnnny/proj.android'
/Users/arianna/android/android-ndk-r8d/sources/cxx-stl/stlport/stlport/stl/_alloc.h:161: error: undefined reference to 'std::__node_alloc::_M_deallocate(void*, unsigned int)'
/Users/arianna/android/android-ndk-r8d/sources/cxx-stl/stlport/stlport/stl/_string.c:600: error: undefined reference to 'std::__stl_throw_length_error(char const*)'
/Users/arianna/android/cocos2d-2.0-x-2.0.4/grannnnnnny/proj.android/../../cocos2dx/actions/CCActionInterval.cpp:386: error: undefined reference to '__dynamic_cast'
/Users/arianna/android/cocos2d-2.0-x-2.0.4/grannnnnnny/proj.android/../../cocos2dx/actions/CCActionInterval.cpp:1783: error: undefined reference to '__dynamic_cast'
/Users/arianna/android/cocos2d-2.0-x-2.0.4/grannnnnnny/proj.android/../../cocos2dx/actions/CCActionInterval.cpp:1838: error: undefined reference to '__dynamic_cast'
/Users/arianna/android/cocos2d-2.0-x-2.0.4/grannnnnnny/proj.android/../../cocos2dx/actions/CCActionInterval.cpp:1906: error: undefined reference to '__dynamic_cast'
/Users/arianna/android/android-ndk-r8d/sources/cxx-stl/stlport/stlport/stl/_vector.c:41: error: undefined reference to 'std::__stl_throw_length_error(char const*)'
/Users/arianna/android/android-ndk-r8d/sources/cxx-stl/stlport/stlport/stl/_vector.c:45: error: undefined reference to 'std::__stl_throw_out_of_range(char const*)'
/Users/arianna/android/android-ndk-r8d/sources/cxx-stl/stlport/stlport/stl/_string.c:604: error: undefined reference to 'std::__stl_throw_out_of_range(char const*)'
/Users/arianna/android/android-ndk-r8d/sources/cxx-stl/stlport/stlport/stl/_vector.c:41: error: undefined reference to 'std::__stl_throw_length_error(char const*)'
./obj/local/armeabi/libcocos2d.a(CCDirector.o):CCDirector.cpp:function typeinfo for cocos2d::CCDirector: error: undefined reference to 'vtable for __cxxabiv1::__vmi_class_type_info'
/Users/arianna/android/android-ndk-r8d/sources/cxx-stl/stlport/stlport/stl/_vector.c:41: error: undefined reference to 'std::__stl_throw_length_error(char const*)'
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi/libgame.so] Error 1
Any help much appreciated, thanks...
Try this in application.mk APP_STL := gnustl_static?
You get the above undefined reference error because you have not added the necessary libraries in Android.mk files. It looks something like this
LOCAL_LDLIBS := -L$(call host-path, $(LOCAL_PATH)/../../libs/$(TARGET_ARCH_ABI)) \
-lcocos2d -lGLESv1_CM -llog -lgame_logic
I am stuck with this issue even after adding the libraries. Its got something to do with setting path but I dont know how to..
If you solve this let me know

NDK-build causes error

I had been trying to solve this issue for quiet a long time,I am using a library called FreeImage and when tries to do the NDK build the code results in following error
My source can be downloaded from
copy.html">http://www.4shared.com/zip/1C3vpLI7/android-imagefilter-ndk_copy.html
Thanking you in advance for your valuable efforts-
tribute.cpp+0x8): undefined reference to `std::ios_base::Init::Init()'
ImfChromaticitiesAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfChromaticitiesAttribute.cpp+0x24): undefined reference to `std::ios_base::Init::~Init()'
/home/flock/ANDROID/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Dwarf Error: mangled line number section.
./obj/local/armeabi/libfreeimage.a(ImfCompressionAttribute.o): In function `_GLOBAL__sub_I_ImfCompressionAttribute.cpp':
ImfCompressionAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfCompressionAttribute.cpp+0x8): undefined reference to `std::ios_base::Init::Init()'
ImfCompressionAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfCompressionAttribute.cpp+0x24): undefined reference to `std::ios_base::Init::~Init()'
./obj/local/armeabi/libfreeimage.a(ImfCompressor.o): In function `Imf::newCompressor(Imf::Compression, unsigned int, Imf::Header const&)':
ImfCompressor.cpp:(.text._ZN3Imf13newCompressorENS_11CompressionEjRKNS_6HeaderE+0x10): undefined reference to `__gnu_thumb1_case_uqi'
ImfCompressor.cpp:(.text._ZN3Imf13newCompressorENS_11CompressionEjRKNS_6HeaderE+0xb8): undefined reference to `__cxa_end_cleanup'
./obj/local/armeabi/libfreeimage.a(ImfCompressor.o):(.ARM.extab.text._ZN3Imf13newCompressorENS_11CompressionEjRKNS_6HeaderE+0x0): undefined reference to `__gxx_personality_v0'
./obj/local/armeabi/libfreeimage.a(ImfCompressor.o): In function `Imf::newTileCompressor(Imf::Compression, unsigned int, unsigned int, Imf::Header const&)':
ImfCompressor.cpp:(.text._ZN3Imf17newTileCompressorENS_11CompressionEjjRKNS_6HeaderE+0x12): undefined reference to `__gnu_thumb1_case_uqi'
ImfCompressor.cpp:(.text._ZN3Imf17newTileCompressorENS_11CompressionEjjRKNS_6HeaderE+0x64): undefined reference to `__cxa_allocate_exception'
ImfCompressor.cpp:(.text._ZN3Imf17newTileCompressorENS_11CompressionEjjRKNS_6HeaderE+0x8a): undefined reference to `__cxa_throw'
ImfCompressor.cpp:(.text._ZN3Imf17newTileCompressorENS_11CompressionEjjRKNS_6HeaderE+0xe4): undefined reference to `__cxa_end_cleanup'
./obj/local/armeabi/libfreeimage.a(ImfCompressor.o):(.ARM.extab.text._ZN3Imf17newTileCompressorENS_11CompressionEjjRKNS_6HeaderE+0x0): undefined reference to `__gxx_personality_v0'
./obj/local/armeabi/libfreeimage.a(ImfCompressor.o): In function `_GLOBAL__sub_I_ImfCompressor.cpp':
ImfCompressor.cpp:(.text.startup._GLOBAL__sub_I_ImfCompressor.cpp+0x8): undefined reference to `std::ios_base::Init::Init()'
ImfCompressor.cpp:(.text.startup._GLOBAL__sub_I_ImfCompressor.cpp+0x24): undefined reference to `std::ios_base::Init::~Init()'
./obj/local/armeabi/libfreeimage.a(ImfCompressor.o):(.data.rel.ro+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
/home/flock/ANDROID/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Dwarf Error: mangled line number section.
./obj/local/armeabi/libfreeimage.a(ImfConvert.o): In function `_GLOBAL__sub_I_ImfConvert.cpp':
ImfConvert.cpp:(.text.startup._GLOBAL__sub_I_ImfConvert.cpp+0x8): undefined reference to `std::ios_base::Init::Init()'
ImfConvert.cpp:(.text.startup._GLOBAL__sub_I_ImfConvert.cpp+0x24): undefined reference to `std::ios_base::Init::~Init()'
/home/flock/ANDROID/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Dwarf Error: mangled line number section.
./obj/local/armeabi/libfreeimage.a(ImfDoubleAttribute.o): In function `_GLOBAL__sub_I_ImfDoubleAttribute.cpp':
ImfDoubleAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfDoubleAttribute.cpp+0x8): undefined reference to `std::ios_base::Init::Init()'
ImfDoubleAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfDoubleAttribute.cpp+0x24): undefined reference to `std::ios_base::Init::~Init()'
/home/flock/ANDROID/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Dwarf Error: mangled line number section.
./obj/local/armeabi/libfreeimage.a(ImfEnvmapAttribute.o): In function `_GLOBAL__sub_I_ImfEnvmapAttribute.cpp':
ImfEnvmapAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfEnvmapAttribute.cpp+0x8): undefined reference to `std::ios_base::Init::Init()'
ImfEnvmapAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfEnvmapAttribute.cpp+0x24): undefined reference to `std::ios_base::Init::~Init()'
My Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE:= freeimage
LOCAL_SRC_FILES :=libfreeimage.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE:= imageprocessing
LOCAL_SRC_FILES:= imageprocessing.c
LOCAL_STATIC_LIBRARIES = freeimage
LOCAL_EXPORT_C_INCLUDES := freeimage.h
LOCAL_LDLIBS:= -lm -llog -ljnigraphics
include $(BUILD_SHARED_LIBRARY)
My application.mk
APP_OPTIM := release
APP_PLATFORM := android-8
APP_STL := gnustl_static
APP_CPPFLAGS += -frtti
APP_CPPFLAGS += -fexceptions
APP_CPPFLAGS += -DANDROID
APP_ABI:= armeabi
I think you are seeing a bug in gcc/NDK that manifests itself slightly differently on Linux, Cygwin, and Windows (non Cygwin).
Here's what I did to fix it (works for Linux and for one of my developers who is blind and has to use Cygwin)...
- Remove the line that says, APP_STL := gnustl_static from your Application.mk (it's broken in the NDK; moreover, it's broken slightly differently on Linux Cygwin, Windows)
- add three lines to Andriod.mk that say,
LOCAL_C_INCLUDES := $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.6/include
LOCAL_C_INCLUDES += $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include
$(LOCAL_LDLIBS) += $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/libgnustl_static.a
^^^This line must be near the end of your $(LOCAL_LDLIBS)
The forgoing will accomplish what having, "APP_STL := gnustl_static" in your Application.mk was supposed to.

Categories

Resources