尝试在 Windows 上使用 Android Studio 设置适用于 Android 的 GStreamer。我主要遵循他们的教程site https://gstreamer.freedesktop.org/documentation/installing/for-android-development.html尽我所能,以及看着this https://codelabs.developers.google.com/codelabs/android-studio-jni/index.html?index=..%2F..%2Findex#0(加上我能找到的任何有帮助的东西)。我得到一个:
错误:错误:参数“-fuse-ld=gold”中的链接器名称无效
我的 Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := app
LOCAL_SRC_FILES := app-1.c
LOCAL_SHARED_LIBRARIES := gstreamer_android
LOCAL_LDLIBS := -landroid
include $(BUILD_SHARED_LIBRARY)
ifndef GSTREAMER_ROOT
ifndef GSTREAMER_ROOT_ANDROID
$(error GSTREAMER_ROOT_ANDROID is not defined!)
endif
GSTREAMER_ROOT := $(GSTREAMER_ROOT_ANDROID)
endif
GSTREAMER_NDK_BUILD_PATH := $(GSTREAMER_ROOT)\share\gst-android\ndk-build
GSTREAMER_PLUGINS := coreelements ogg theora vorbis videoconvert audioconvert audioresample playback glimagesink soup opensles
G_IO_MODULES := gnutls
GSTREAMER_EXTRA_DEPS := gstreamer-video-1.0
include $(GSTREAMER_NDK_BUILD_PATH)\gstreamer-1.0.mk
和应用程序/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.quant.icarus"
minSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
ndkBuild {
def gstRoot
if (project.hasProperty('gstAndroidRoot'))
gstRoot = project.gstAndroidRoot
else
gstRoot = System.env.GSTREAMER_ROOT_ANDROID
if (gstRoot == null)
throw new GradleException('GSTREAMER_ROOT_ANDROID must be set, or "gstAndroidRoot" must be defined in your gradle.properties in the top level directory of the unpacked universal GStreamer Android binaries')
arguments "NDK_APPLICATION_MK=src/main/jni/Application.mk", "GSTREAMER_JAVA_SRC_DIR=src/main/java", "GSTREAMER_ROOT_ANDROID=$gstRoot", "GSTREAMER_ASSETS_DIR=src/main/assets"
targets "app", "gstreamer_android"
// All archs except MIPS and MIPS64 are supported
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a'
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
}
afterEvaluate {
compileDebugJavaWithJavac.dependsOn 'externalNativeBuildDebug'
compileReleaseJavaWithJavac.dependsOn 'externalNativeBuildRelease'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
Gradle 项目同步运行没有任何问题。但是 Make Project 会产生以下结果:
错误:错误:参数“-fuse-ld=gold”中的链接器名称无效
或者更详细:
* What went wrong:
Execution failed for task ':app:externalNativeBuildDebug'.
> Build command failed.
Error while executing process C:\Users\Quant\AppData\Local\Android\Sdk\ndk-bundle\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=C:\Users\Quant\AndroidStudioProjects\Icarus\app\src\main\jni\Android.mk NDK_APPLICATION_MK=C:\Users\Quant\AndroidStudioProjects\Icarus\app\src\main\jni\Application.mk APP_ABI=arm64-v8a NDK_ALL_ABIS=arm64-v8a NDK_DEBUG=1 APP_PLATFORM=android-23 NDK_OUT=C:/Users/Quant/AndroidStudioProjects/Icarus/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=C:\Users\Quant\AndroidStudioProjects\Icarus\app\build\intermediates\ndkBuild\debug\lib NDK_APPLICATION_MK=src/main/jni/Application.mk GSTREAMER_JAVA_SRC_DIR=src/main/java GSTREAMER_ROOT_ANDROID=C:\Users\Quant\Desktop\GStreamer\arm GSTREAMER_ASSETS_DIR=src/main/assets gst-build-arm64-v8a/libgstreamer_android.so}
GStreamer : [GEN] => gst-build-arm64-v8a/gstreamer_android.c
GStreamer : [COMPILE] => gst-build-arm64-v8a/gstreamer_android.c
GStreamer : [LINK] => gst-build-arm64-v8a/libgstreamer_android.so
clang.exe: error: invalid linker name in argument '-fuse-ld=gold'
make: *** [buildsharedlibrary_arm64-v8a] Error 1
有想法该怎么解决这个吗?我见过一些线程说要添加标志以使其成为 gold.exe...但没有人说标志的设置位置(并且线程似乎并没有完全解决)。
我按照 gstreamer 安装指南中的指示替换了“ld.exe”文件,即使它看起来已经过时(我在收到相同的错误后这样做了 - 所以这不是导致它的原因)。
这是一个问题clang.exe
尝试将库链接在一起的过程。注意,无需更改ld.exe
文件如问题中链接的安装说明所示。
修复:您需要更改 GStreamer 目录中每个架构的两个文件,以便链接器被调用为gold.exe
并不是gold
.
对于您感兴趣的每种架构,您需要访问(以arm64为例):
1)
path\to\Gstreamer\root\arm64\share\gst-android\ndk-build\gstreamer-1.0.mk
并改变-fuse-ld=gold
to -fuse-ld=gold.exe
(它只在文件中出现一次)。
现在转到:
2)
path\to\Gstreamer\root\arm64\include\gmp.h
并改变-fuse-ld=gold
to -fuse-ld=gold.exe
(同样,仅出现一次)。
我的帖子有一些小修正Android.mk
and gradle
文件来完全编译,但这似乎超出了这个问题的范围(将 -llog 添加到本地 ldlibs 并仅使用核心插件)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)