Cannot link freetype.a on Android - android

i try to use freetype lib in my project with cocos2d-x. I built freetype and added to the project(like here http://en.wikibooks.org/wiki/OpenGL_Programming/Installation/Android_NDK#FreeType ). In xcode it builds without errors. Now I trying to use it on android. I made make file in freetype dir:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := freetype
LOCAL_SRC_FILES := lib/libfreetype.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/include/freetype2
include $(PREBUILT_STATIC_LIBRARY)
and added to main makefile
LOCAL_STATIC_LIBRARIES := freetype curl_static_prebuilt
...
$(call import-module,freetype)
during linking has the error: libfreetype.a: file format not recognized; treating as linker script
Prebuilt : libfreetype.a <=
/Users/user/Development/Slots/Slots_Android/lib/freetype/lib/
SharedLibrary : libgame.so
/Users/user/Development/android_ndk_r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6.x-google/../../../../arm-linux-androideabi/bin/ld:./obj/local/armeabi/libfreetype.a:
file format not recognized; treating as linker script
/Users/user/Development/android_ndk_r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6.x-google/../../../../arm-linux-androideabi/bin/ld:./obj/local/armeabi/libfreetype.a:1:
syntax error collect2: ld returned 1 exit status
How to fix it?

Related

Android executable missing static library

guys,
My XXX.mk for building the Android executable XXX describes like this:
...
LOCAL_STATIC_LIBRARIES := \
libYYY
LOCAL_MODULE := XXX
LOCAL_PROPRIETARY_MODULE := $(ENABLE_VENDOR_MODULE)
LOCAL_32_BIT_ONLY := true
include $(BUILD_EXECUTABLE)
It is the same directory with the prebuilt libYYY.a and an Android.mk like this:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/XXX.mk
When executing mm command,
I got the following error:
FAILED: XXX.mk: error: "XXX(EXECUTABLES android-arm) missing libYYY
(STATIC_LIBRARIES android-arm)"
The error is still there even I tried to change LOCAL_STATIC_LIBRARIES to libYYY.a or YYY.
Any suggestion?

Compile C++ native activity with NDK

I create Android native activity project based on "native-activity" project in NDK. In this project android_main function is implemented in main.c file and it compiles and run without any issues.
Now I wants to implement some C++ routines in this file and to do that, as a first step I change main.c file to main.cpp and change LOCAL_SRC_FILES entry in Android.mk to main.cpp.
After this change I got following error at the compilation:
make.exe: *** No rule to make target `jni/main.c', needed by `obj/local/arm64-v8a/objs/native-activity/main.o'. Stop.
Also Android.mk file in this project contain following entries:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := native-activity
LOCAL_SRC_FILES := main.cpp
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM -lGLESv2
LOCAL_STATIC_LIBRARIES := android_native_app_glue
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)
What was the possible cause for this error?
Delete your obj directory from workspace and rebuild. Sometimes eclipse clean is not working and failed to delete obj files.

Android NDK cannot find -lGLESv

I am getting the following errors when I try to perform an NDK build, can anyone help me please?
I did the setup instruction exactly like what are written in "Beginning Android C++ Game Development". every step except the 9th:
"Click the NativeActivity node in the Application Nodes window and click Add once more. Enter the Name as android.app.lib_name and the Value as the LOCAL_MODULE name, which can be found in the Android.mk file in the project’s jni folder."
Errors :
10:44:23 ** Incremental Build of configuration Default for project
HelloDroid ** "C:\ndk\ndk-build.cmd" all Android NDK:
WARNING:jni/Android.mk:HelloDroid-Test: non-system libraries in linker
flags: -lGLESv Android NDK: This is likely to result in
incorrect builds. Try using LOCAL_STATIC_LIBRARIES Android NDK:
or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of
the Android NDK: current module [armeabi] SharedLibrary :
libHelloDroid-Test.so
C:/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:
error: cannot find -lGLESv collect2: ld returned 1 exit status
make.exe: * [obj/local/armeabi/libHelloDroid-Test.so] Error 1
10:44:23 Build Finished (took 226ms)
I found the problem.
I just needed to edit the Android.mk
it now looks like this:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hellodroid
LOCAL_SRC_FILES := hellodroid.cpp
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv2
LOCAL_STATIC_LIBRARIES := android_native_app_glue
include $(BUILD_SHARED_LIBRARY)
$(call import-module, android/native_app_glue)
As the error states, there is no lib GLESv.
Which version of OpenGL ES are you using, 1 or 2?
The linker flags are -lGLESv1_CM and -lGLESv2, respectively.

Android.mk: how to include ffmpeg and Opencv

this is my project situation: I compiled ffmpeg in windows using this tutorial and I imported the ffmpeg folder (with inside libffmpeg.so file) generated inside my android project (under jni folder).
In my project I have a jni_part.cpp where I inserted my jni function to operate with opencv.
In my Android.mk I'm using the code below to import opencv and compile the jni_part.cpp
include $(CLEAR_VARS)
include ../../sdk/native/jni/OpenCV.mk
LOCAL_MODULE := mixed_sample
LOCAL_SRC_FILES := jni_part.cpp
LOCAL_LDLIBS += -llog -ldl
LOCAL_SHARED_LIBRARY := ffmpeg-prebuilt
include $(BUILD_SHARED_LIBRARY)
But what code I should use to import also ffmpeg? I tried to use this code:
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg-prebuilt
LOCAL_SRC_FILES := ffmpeg-0.8/android/armv7-a/libffmpeg.so
LOCAL_EXPORT_C_INCLUDES := ffmpeg-0.8/android/armv7-a/include/
LOCAL_EXPORT_LDLIBS := ffmpeg-0.8/android/armv7-a/libffmpeg.so
LOCAL_PRELINK_MODULE := true
include $(PREBUILT_SHARED_LIBRARY)
but if from my jni_part.cpp code I try to include some ffmpeg files/libraries "#include <libavutil/avstring.h>" I get this error:
**** Build of configuration Default for project OpenCV Tutorial 4 - Mix Java+Native OpenCV ****
C:\android-ndk-r8c\ndk-build.cmd
Prebuilt : libffmpeg.so <= jni/ffmpeg-0.8/android/armv7-a/
Install : libffmpeg.so => libs/armeabi-v7a/libffmpeg.so
"Compile++ thumb : mixed_sample <= jni_part.cpp
jni/jni_part.cpp:24:32: fatal error: libavutil/avstring.h: No such file or directory
compilation terminated.
make: *** [obj/local/armeabi-v7a/objs/mixed_sample/jni_part.o] Error 1
**** Build Finished ****
Someone could help me please? I need to do this to include ffmpeg codec with the hope to use the function cvCaptureFromAVi...
Thanks in advance

android build static lib

I am planning to user static Linux .a library into android.
I have created static .a file using following link http://codingfreak.blogspot.in/2010/01/creating-and-using-static-libraries-in.html
i have following Android.mk file in my Android application.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE:= first-prebuilt
LOCAL_SRC_FILES:= libarith.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := test-main
LOCAL_STATIC_LIBRARIES := first-prebuilt
LOCAL_SRC_FILES := native.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
include $(BUILD_SHARED_LIBRARY)
When I build application using ndk-build r7b, it gives following error.
Сompile++ thumb : test-main <= native.cpp
SharedLibrary : libtest-main.so
/home/hiren/NDK-r7b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: /home/hiren/workspace/VideoTEST/obj/local/armeabi/libarith.a(addition.o): Relocations in generic ELF (EM: 3)
/home/hiren/workspace/VideoTEST/obj/local/armeabi/libarith.a: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make: *** [/home/hiren/workspace/VideoTEST/obj/local/armeabi/libtest-main.so] Error 1
Can anyone help, I am stuck for a long time, here...
Thanks in advance.
You need to build your static librariy in the android format. See also Error in linking C++ static library with android ndk(Error: file format not recognized)

Categories

Resources