Android NDK链接器(GStreamer)-无效的链接器名称-fuse-ld = gold [英] Android NDK Linker (GStreamer) - invalid linker name -fuse-ld=gold

查看:84
本文介绍了Android NDK链接器(GStreamer)-无效的链接器名称-fuse-ld = gold的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在Windows上使用Android Studio设置Android的GStreamer.我主要是从他们的站点中最好地学习该教程我可以查看(以及我认为有帮助的所有内容).我得到一个:

错误:错误:参数'-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 

和app/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更改为-fuse-ld=gold.exe(在文件中仅出现一次).

现在转到:

2) path\to\Gstreamer\root\arm64\include\gmp.h并将-fuse-ld=gold更改为-fuse-ld=gold.exe(同样,仅出现一次).


对我发布的Android.mkgradle文件进行了一些较小的修复,以使内容可以完全编译,但这似乎超出了此问题的范围(将-llog添加到本地ldlibs中,并且仅使用了核心插件). /p>

Trying to setup GStreamer for Android using Android Studio on Windows. I'm mostly following the tutorial from their site as best I can, as well as looking at this (plus whatever I can find that helps). I get an:

Error:error: invalid linker name in argument '-fuse-ld=gold'

My 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

and app/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 project sync runs without any problems. But Make Project produces the following:

Error:error: invalid linker name in argument '-fuse-ld=gold'

Or more verbose:

* 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

Any ideas on how to fix this? I've seen some threads that say to add flags to make it gold.exe...except no one is saying where the flags are set (and the threads didn't seem all too resolved).

I replaced the 'ld.exe' file as indicated in the gstreamer install guide, even if it seemed dated (I did that after getting the same error - so that's not causing it).

解决方案

It is a problem with the clang.exe process that tries to link together the libraries. Note, there is no need to change the ld.exe file as in the install instructions from the link in the question.


Fix: you need to change two files per architecture in the GStreamer directory so that the linker gets called as gold.exe and not gold.

For each architecture you're interested in you need to go to (using arm64 as an example):

1) path\to\Gstreamer\root\arm64\share\gst-android\ndk-build\gstreamer-1.0.mk and change -fuse-ld=gold to -fuse-ld=gold.exe (it only appears once in the file).

Now go to:

2) path\to\Gstreamer\root\arm64\include\gmp.h and change -fuse-ld=gold to -fuse-ld=gold.exe (again, only one occurrence).


There were some minor fixes to my posted Android.mk and gradle files to get things to fully compile, but that seems outside the scope of this question (added -llog to local ldlibs and used only core plugin).

这篇关于Android NDK链接器(GStreamer)-无效的链接器名称-fuse-ld = gold的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆