I am following the tutorial at
http://docs.gstreamer.com/display/GstSDK/Installing+for+Android+development
I would like to use ndk-build to build the example.
When I use "ndk-build", there is an error message.
Here are the output messages:
GStreamer : [GEN] => gst-build/gstreamer_android.c
GStreamer : [COMPILE] => gst-build/gstreamer_android.c
GStreamer : [LINK] => gst-build/libgstreamer_android.so
/home/quanta/tools/android-ndk-r9d/toolchains/arm-linux-androideabi-
4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.gold: error: cannot find -lrt
collect2: ld returned 1 exit status
make: *** [buildsharedlibrary] Error 1
I use ndk-r9d in ubuntu linux 64bit 12.04
Many thanks for any suggestion.
Add Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := tutorial-1
LOCAL_SRC_FILES := tutorial-1.c
LOCAL_SHARED_LIBRARIES := gstreamer_android
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
ifndef GSTREAMER_SDK_ROOT
ifndef GSTREAMER_SDK_ROOT_ANDROID
$(error GSTREAMER_SDK_ROOT_ANDROID is not defined!)
endif
GSTREAMER_SDK_ROOT := $(GSTREAMER_SDK_ROOT_ANDROID)
endif
GSTREAMER_NDK_BUILD_PATH := $(GSTREAMER_SDK_ROOT)/share/gst-android/ndk- build/
GSTREAMER_PLUGINS := coreelements
include $(GSTREAMER_NDK_BUILD_PATH)/gstreamer.mk
LOCAL_LDLIBS := -llog
to
LOCAL_LDLIBS := -llog -landroid
Android doesn't have a librt. It's all in libc.
Presumably include $(GSTREAMER_NDK_BUILD_PATH)/gstreamer.mk is adding -lrt to ldlibs.
Related
I get this error while running build-ndk for my ffmpeg android project
make: *** [obj/local/armeabi-v7a/libffmpeg-test-jni.so]
undefined reference to 'av_close_input_file'
undefined reference to 'av_find_stream_info'
undefined reference to 'av_open_input_file'
undefined reference to 'avcodec_open'
Any solutions to get rid of this error ? I am very new to ffmpeg and Android NDK
This is my Android MK file
LOCAL_PATH := $(call my-dir)
#declare the prebuilt library
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg-prebuilt
LOCAL_SRC_FILES := ffmpeg-2.5.4/android/armv7-a/libffmpeg.so
LOCAL_EXPORT_C_INCLUDES := ffmpeg-2.5.4/android/armv7-a/include
LOCAL_EXPORT_LDLIBS := ffmpeg-2.5.4/android/armv7-a/libffmpeg.so
LOCAL_LDLIBS += -llog -lavutil -lavformat -lavcodec -lz -lavutil -lm
LOCAL_PRELINK_MODULE := true
include $(PREBUILT_SHARED_LIBRARY)
#the andzop library
include $(CLEAR_VARS)
LOCAL_ALLOW_UNDEFINED_SYMBOLS=false
LOCAL_MODULE := ffmpeg-test-jni
LOCAL_SRC_FILES := ffmpeg-test-jni.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/ffmpeg-2.5.4/android/armv7-a/include
LOCAL_SHARED_LIBRARY := ffmpeg-prebuilt
LOCAL_LDLIBS := -llog -ljnigraphics -lz -lm $(LOCAL_PATH)/ffmpeg-2.5.4/android/armv7-a/libffmpeg.so
include $(BUILD_SHARED_LIBRARY)
Any Pointers much appreciated
Thanks!
I'm trying to develope a native code with OpenCV using IntelliJ IDEA 13.1.4. When I try to ndk-build the code provided in mixedprocessing sample, I have this error:
[armeabi-v7a] Compile++ thumb: com_sample_jniLib <= com_sample_jniLib.cpp
[armeabi-v7a] SharedLibrary : libcom_sample_jniLib.so
D:/Workspace/android-ndk-r10/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 -lopencv_java
make.exe: *** [obj/local/armeabi-v7a/libcom_voxar_tracker_TrackerLib.so] Error 1
D:\Workspace\android-ndk-r10\sources\cxx-stl\stlport\stlport
Basically, he can't find -lopencv_java.
Here is my Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include jni/opencv/OpenCV.mk
LOCAL_SRC_FILES := com_voxar_tracker_TrackerLib.cpp
LOCAL_MODULE := com_voxar_tracker_TrackerLib
LOCAL_LDLIBS += -llog -ldl
include $(BUILD_SHARED_LIBRARY)
And my Application.mk:
APP_STL := stlport_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := all
As I told before, I'm using IntelliJ IDEA 13.1.4, OpenCV 2.4.9 and Android NDK r10 32-bit on Windows 8.1. Does anybody have any idea of what that could be?
You seem to have forgot OPENCV_INSTALL_MODULES:=on in your Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
OPENCV_INSTALL_MODULES:=on
include jni/opencv/OpenCV.mk
LOCAL_SRC_FILES := com_voxar_tracker_TrackerLib.cpp
LOCAL_MODULE := com_voxar_tracker_TrackerLib
LOCAL_LDLIBS += -llog -ldl
include $(BUILD_SHARED_LIBRARY)
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := test
LOCAL_CFLAGS := -Wall
LOCAL_SRC_FILES := test.c
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM
include $(BUILD_SHARED_LIBRARY)
I run....
ndk-build NDK_PROJECT_PATH=./ APP_BUILD_SCRIPT=./Android.mk
and I get....
Compile thumb : test <= test.c
./test.c:8:29: fatal error: GLES/gl.h: No such file or directory
compilation terminated.
make: * [obj/local/armeabi/objs/test/test.o] Error 1
Now I am guessing adding a cflag of -I/include or a C_Include in the Android.mk will work but shouldn't that be handled by the -lGLESv1_CM.
Making an Application.mk file worked for me....
APP_ABI := armeabi armeabi-v7a
APP_PLATFORM := android-8
I am unable to load -landroid lib in my package, I am using following Android.mk
code
include $(CLEAR_VARS)
LOCAL_MODULE := ShirtsAR
TARGET_PLATFORM := android-5
USE_OPENGL_ES_1_1 := false
ifeq ($(USE_OPENGL_ES_1_1), true)
OPENGLES_LIB := -lGLESv1_CM
OPENGLES_DEF := -DUSE_OPENGL_ES_1_1
else
OPENGLES_LIB := -lGLESv2
OPENGLES_DEF := -DUSE_OPENGL_ES_2_0
endif
ANDROID_LIB := -landroid
LOCAL_SRC_FILES := ShirtsAR.cpp
LOCAL_CFLAGS := -Wno-write-strings $(OPENGLES_DEF)
LOCAL_LDLIBS := -llog $(OPENGLES_LIB) $(ANDROID_LIB)
LOCAL_ARM_MODE := arm
include $(BUILD_SHARED_LIBRARY)
Please guide, I am stuck.. :(
getting following error
/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld.exe: cannot find -landroid
collect2: ld returned 1 exit status
make: * [obj/local/armeabi/libShirtsAR.so] Error 1
Native Activity is only supported with API level 9 and higher (see docs/STABLE-APIS.html in your NDK distribution). So if you want to link against libandroid you'll need to change to
TARGET_PLATFORM := android-9
I have to use this APP_PLATFORM variable in the Application.mk file. I was able to build my solution after this.
Example:
APP_PLATFORM := android-22
Today October 2017 TARGET_PLATFORM doesn't work for me.
Cheers.
I started off creating libraries as shared libraries, but I considered it would be more efficient to create one shared libraries and the rest static. When it was all shared, it compiled and linked fine, but moving to static, I get on linking "undefined reference".
Edit: I build all the libraries in one Android.mk
Android.mk:
MY_LOCAL_PATH := $(call my-dir)
MY_LOCAL_CFLAGS := -DDEBUG
TARGET_PLATFORM := 'android-4'
LOCAL_PATH := $(MY_LOCAL_PATH)/../../Base
include $(CLEAR_VARS)
LOCAL_MODULE := Base
LOCAL_SRC_FILES := <Base src files>
include $(BUILD_STATIC_LIBRARY)
MY_LOCAL_STATIC_LIBRARIES := Base
MY_LOCAL_C_INCLUDES := $(MY_LOCAL_PATH)/../../Base
LOCAL_PATH := $(MY_LOCAL_PATH)/../../Framework
include $(CLEAR_VARS)
LOCAL_MODULE := Framework
LOCAL_C_INCLUDES := $(MY_LOCAL_C_INCLUDES)
LOCAL_SRC_FILES := <Framework src files>
LOCAL_CFLAGS := $(MY_LOCAL_CFLAGS)
include $(BUILD_STATIC_LIBRARY)
MY_LOCAL_STATIC_LIBRARIES += Framework
MY_LOCAL_C_INCLUDES += $(MY_LOCAL_PATH)/../../Framework
LOCAL_PATH := $(MY_LOCAL_PATH)/Graphics
include $(CLEAR_VARS)
LOCAL_MODULE := Graphics
LOCAL_SRC_FILES := <Graphics src files>
LOCAL_EXPORT_LDLIBS := -lGLESv1_CM
LOCAL_CFLAGS := $(MY_LOCAL_CFLAGS)
LOCAL_C_INCLUDES := $(MY_LOCAL_C_INCLUDES)
include $(BUILD_STATIC_LIBRARY)
MY_LOCAL_STATIC_LIBRARIES += Graphics
MY_LOCAL_C_INCLUDES += $(MY_LOCAL_PATH)/Graphics
LOCAL_PATH := $(MY_LOCAL_PATH)/Platform
include $(CLEAR_VARS)
LOCAL_MODULE := Platform
LOCAL_SRC_FILES := <Platform src files>
LOCAL_CFLAGS := $(MY_LOCAL_CFLAGS)
LOCAL_C_INCLUDES := $(MY_LOCAL_C_INCLUDES)
include $(BUILD_STATIC_LIBRARY)
MY_LOCAL_STATIC_LIBRARIES += Platform
MY_LOCAL_C_INCLUDES += $(MY_LOCAL_PATH)/Platform
LOCAL_PATH := $(MY_LOCAL_PATH)
include $(CLEAR_VARS)
LOCAL_MODULE := Final
LOCAL_SRC_FILES := <Final src files>
LOCAL_STATIC_LIBRARIES := $(MY_LOCAL_STATIC_LIBRARIES)
LOCAL_LDLIBS := -llog
LOCAL_CFLAGS := $(MY_LOCAL_CFLAGS)
LOCAL_C_INCLUDES := $(MY_LOCAL_C_INCLUDES)
include $(BUILD_SHARED_LIBRARY)
Last line of ndk-build V=1 -B:
SharedLibrary : libFinal.so
/Users/robbie/Library/Frameworks/Android-NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-g++ -Wl,-soname,libFinal.so -shared --sysroot=/Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm <object files> /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libBase.a /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libFramework.a /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libGraphics.a /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libPlatform.a /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libstdc++.a /Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib/libc.so /Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib/libstdc++.so /Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib/libm.so -Wl,--no-undefined -Wl,-z,noexecstack -L/Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib -llog -lGLESv1_CM -lstdc++ -Wl,-rpath-link=/Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib -lsupc++ -o /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libFinal.so
/Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libPlatform.a(ATexture.o): In function `ATexture':
/Users/robbie/Documents/Apps/Revolution/Android/jni/SpinTap/ATexture.cpp:9: undefined reference to `TextureRenderer::TextureRenderer(unsigned int)'
/Users/robbie/Documents/Apps/Revolution/Android/jni/SpinTap/ATexture.cpp:9: undefined reference to `TextureRenderer::TextureRenderer(unsigned int)'
Edit2: TextureRenderer is in Graphics, which is included.
Does anyone have an idea why it may not be working and how to fix it?
This looks like an order-of-linking issue to me.
Your command line is:
arm-linux-androideabi-g++ -Wl,-soname,libFinal.so -shared \
libBase.a libFramework.a libGraphics.a libPlatform.a -o libFinal.so
and the error is
libPlatform.a(ATexture.o): In function `ATexture':
ATexture.cpp:9: undefined reference to `TextureRenderer'
ATexture.cpp:9: undefined reference to `TextureRenderer'
TextureRenderer is in Graphics. But libGraphics is before libPlatform on the command line. g++ will search each library on the command line in the order they are given, loading functions to resolve external references. It will read libGraphics once, load the functions that resolve external references and move on to libPlatform.
Try changing LOCAL_STATIC_LIBRARIES := $(MY_LOCAL_STATIC_LIBRARIES) to LOCAL_STATIC_LIBRARIES := Platform Graphics Framework Base and see how you get on.
In your Android.mk, make sure you are referencing the static library with the proper call:
LOCAL_STATIC_LIBRARIES := mystaticlibproj
before calling include $(BUILD_SHARED_LIBRARY).
Then, at the end of the file, place the call to import the static lib module
$(call import-module, mystaticlibproj)
If you're still having trouble, post the verbose build log (ndk-build V=1 -B) and your Android.mk