0
votes

I'm trying to use Freetype with Android NDK + Eclipse, but I got an error when I include this in my project:

#include <ft2build.h>
#include FT_FREETYPE_H

Error message:

fatal error: ft2build.h: No such file or directory

Here is the Android.mk in jni/freetype2:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := freetype
LOCAL_SRC_FILES := freetype/lib/libfreetype.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/freetype/include/freetype2 $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)

Here is the project's Android.mk (in jni folder):

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := CNSD_CPP
...
LOCAL_LDLIBS := -landroid -lGLESv2 -lEGL -llog
LOCAL_STATIC_LIBRARIES := freetype android_native_app_glue
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)

And I have that header file in the dir:

jni/freetype2/freetype/include/freetype2

and when I CTRL+Click on it, the Eclipse shows me the file. What am I doing wrong?


@Alex: I ran ndk-build V=1 and the end of the result is this:

[armeabi] Compile++ thumb: CNSD_CPP <= Log.cpp d:/Development/Android/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ -MMD -MP -MF D:/Development/Projects/workspace/CNSD_CPP//obj/local/armeabi/objs/CNSD_CPP/Log .o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -fno-rtti -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Id:/Development/Android/android-ndk-r9c/sources/android/native_app_glue -Id:/Development/Android/android-ndk-r9c/sources/cxx-stl/gnu-libstdc++/4.8/include -Id:/Development/Android/android-ndk-r9c/sources /cxx-stl/gnu-libstdc++/4.8/libs/armeabi/include -Id:/Development/Android/android-ndk-r9c/sources/cxx-stl/gnu-libstdc++/4.8/include/backward -ID:/Development/Projects/workspace/CNSD_CPP//jni -DANDROID -Wa,--noexecstack -Wf ormat -Werror=format-security -std=c++11 -Id:/Development/Android/android-ndk-r9c/platforms/android-15/arch-arm/usr/include -c D:/Development/Projects/workspace/CNSD_CPP//jni/Log.cpp -o D:/Development/Projects/workspa ce/CNSD_CPP//obj/local/armeabi/objs/CNSD_CPP/Log.o [armeabi] Compile++ thumb: CNSD_CPP <= Main.cpp d:/Development/Android/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ -MMD -MP -MF D:/Development/Projects/workspace/CNSD_CPP//obj/local/armeabi/objs/CNSD_CPP/Mai n.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -fno-rtti -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Id:/Development/Android/android-ndk-r9c/sources/android/native_app_glue -Id:/Development/Android/android-ndk-r9c/sources/cxx-stl/gnu-libstdc++/4.8/include -Id:/Development/Android/android-ndk-r9c/source s/cxx-stl/gnu-libstdc++/4.8/libs/armeabi/include -Id:/Development/Android/android-ndk-r9c/sources/cxx-stl/gnu-libstdc++/4.8/include/backward -ID:/Development/Projects/workspace/CNSD_CPP//jni -DANDROID -Wa,--noexecstack -W format -Werror=format-security -std=c++11 -Id:/Development/Android/android-ndk-r9c/platforms/android-15/arch-arm/usr/include -c D:/Development/Projects/workspace/CNSD_CPP//jni/Main.cpp -o D:/Development/Projects/works pace/CNSD_CPP//obj/local/armeabi/objs/CNSD_CPP/Main.o D:/Development/Projects/workspace/CNSD_CPP//jni/Main.cpp:3:22: fatal error: ft2build.h: No such file or directory #include ^ compilation terminated. make.exe: *** [D:/Development/Projects/workspace/CNSD_CPP//obj/local/armeabi/objs/CNSD_CPP/Main.o] Error 1

1
Try to tun ndk-build V=1 from command line, and post the log. - Alex Cohn

1 Answers

2
votes

Don't use cygwin shell to build with NDK toolchain. Open normal Windows command line, and use ndk-build.cmd instead. Make sure that all paths are specified in so-called mixed format, e.g

d:/Development/Projects/workspace/CNSD_CPP

Update: now I see that

include $(LOCAL_PATH)/freespace2/Android.mk

is missing. It should be placed after BUILD_SHARED_LIBRARY and before include-module.