【发布时间】:2015-06-15 11:38:55
【问题描述】:
我正在按照本教程构建一个 gstreamer 项目 - http://docs.gstreamer.com/display/GstSDK/Android+tutorial+1%3A+Link+against+GStreamer
我在 jni 文件夹中创建了两个名为 main.cpp 和 Android.mk 的文件。 jni 文件夹位于 Android 项目中。不过,无论如何,我认为它的位置并不重要。这些是这两个文件的内容 - Android.mk -
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := test
LOCAL_SRC_FILES := main.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
main.cpp -
#include <string.h>
#include <jni.h>
#include <android/log.h>
#include <gst/gst.h>
jstring gst_native_get_gstreamer_info (JNIEnv* env, jobject thiz) {
char *version_utf8 = gst_version_string();
jstring *version_jstring = (*env)->NewStringUTF(env, version_utf8);
g_free (version_utf8);
return version_jstring;
}
static JNINativeMethod native_methods[] = {
{ "nativeGetGStreamerInfo", "()Ljava/lang/String;", (void *) gst_native_get_gstreamer_info}
};
jint JNI_OnLoad(JavaVM *vm, void *reserved) {
JNIEnv *env = NULL;
if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_4) != JNI_OK) {
__android_log_print (ANDROID_LOG_ERROR, "tutorial-1", "Could not retrieve JNIEnv");
return 0;
}
jclass klass = (*env)->FindClass (env, "com/gst_sdk_tutorials/tutorial_1/Tutorial1");
(*env)->RegisterNatives (env, klass, native_methods, G_N_ELEMENTS(native_methods));
return JNI_VERSION_1_4;
}
当我从这个目录执行ndk-build 时,我得到以下错误 -
make: -n: Command not found
/bin/sh: 0: Illegal option -
/bin/sh: 0: Illegal option -
/bin/sh: 0: Illegal option -
/bin/sh: 0: Illegal option -
/bin/sh: 0: Illegal option -
/bin/sh: 0: Illegal option -
/bin/sh: 0: Illegal option -
/bin/sh: 0: Illegal option -
/bin/sh: 0: Illegal option -
GStreamer : [GEN] => gst-build/gstreamer_android.c
/bin/sh: 1: i: not found
make: [genstatic] Error 127 (ignored)
/bin/sh: 1: i: not found
make: [genstatic] Error 127 (ignored)
/bin/sh: 1: i: not found
make: [genstatic] Error 127 (ignored)
/bin/sh: 1: i: not found
make: [genstatic] Error 127 (ignored)
GStreamer : [COMPILE] => gst-build/gstreamer_android.c
gst-build/gstreamer_android.c:9:2: error: stray '@' in program
@PLUGINS_DECLARATION@
^
gst-build/gstreamer_android.c:9:22: error: stray '@' in program
@PLUGINS_DECLARATION@
^
gst-build/gstreamer_android.c:12:2: error: stray '@' in program
@G_IO_MODULES_DECLARE@
^
gst-build/gstreamer_android.c:9:3: error: unknown type name 'PLUGINS_DECLARATION'
@PLUGINS_DECLARATION@
^
gst-build/gstreamer_android.c:12:23: error: stray '@' in program
@G_IO_MODULES_DECLARE@
^
gst-build/gstreamer_android.c:15:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
然后……
【问题讨论】:
-
您是否按照安装说明进行操作? docs.gstreamer.com/display/GstSDK/…
-
是的。我已经安装并解压了 sdk 并设置了环境变量。
-
make: -n: Command not found... 是否安装了make?
-
是的。它已安装。 ://
-
顺便说一句,在 jni 中,当我执行
ndk-build时,正在创建一个名为gst-build的文件夹。正在该文件夹中创建一个名为gstreamer_android.c的文件。这些是该文件的内容,这就是导致我认为的实际错误的原因。 - pastebin.com/tqSHJRti
标签: android c++ android-ndk gstreamer