2017-06-08 2 views
0

Ich versuche, ffmpeg statische Bibliotheken zu bauen und sie mit einem Android-Projekt zu verknüpfen, um einen Video-Player zu implementieren. Ziel ist es, einen Player in die Lage zu versetzen, Videodateien aus verschiedenen Quellen zu empfangen, ähnlich wie P2P-Filesharing-Netzwerke. (Ziel-Api ist 21 Level, das ist 1 Level kurz von angenommenen offiziellen Lösung mit MediaSource)Linker-Befehl fehlgeschlagen mit Exit-Code 1 beim Erstellen von ffmpeg statischen Bibliotheken

Ich schaffte es zu kompilieren ffmpeg from this repo (der gesamte Code verwendet, wie es ist), aber später habe ich auf ein Verknüpfungsproblem stecken. Immer, wenn ich zu kompilieren versuche wir Liste von ffmpeg Methoden in meinem Code genannt und eine kurze eloquente Nachricht:

Linker Befehl fehlgeschlagen mit Exitcode 1

Ich habe keine Ahnung, wie -v passiert zum Linker im Android Studio. Wäre toll, wenn mich jemand darauf hinweisen würde.

Ich benutze Android Studio, Build mit Gradle und cmake.

Es ist meine Dateien: build.gradle (Projekt)

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.3.1' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

build.gradle (Modul)

apply plugin: 'com.android.application' 

    android { 
     compileSdkVersion 25 
     buildToolsVersion "25.0.3" 
     productFlavors { 
      x86 { 
       ndk { 
        abiFilter "x86" 
       } 
      } 
      arm { 
       ndk { 
        abiFilters "armeabi-v7a" 
       } 
      } 
      armv7 { 
       ndk { 
        abiFilters "armeabi-v7a" 
       } 
      } 
     } 
     defaultConfig { 
      applicationId "com.example.ledo.ndkapplication" 
      minSdkVersion 22 
      targetSdkVersion 25 
      versionCode 1 
      versionName "1.0" 
      testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
      externalNativeBuild { 
       cmake { 
        cppFlags "-std=c++11 -frtti -fexceptions" 
        arguments '-DANDROID_PLATFORM=android-16' 
       } 
      } 
     } 
     buildTypes { 
      release { 
       minifyEnabled false 
       proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
      } 
     } 
     externalNativeBuild { 
      cmake { 
       path "CMakeLists.txt" 
      } 
     } 
     splits { 
      abi { 
       enable true 
       reset() 
       include 'x86', 'armeabi-v7a' 
       universalApk true 
      } 
     } 
    } 

    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' 
     compile 'com.android.support:design:25.3.1' 
     compile 'com.writingminds:FFmpegAndroid:0.3.2' 
     testCompile 'junit:junit:4.12' 
    } 

CMakeLists.txt

# For more information about using CMake with Android Studio, read the 
# documentation: https://d.android.com/studio/projects/add-native-code.html 

# Sets the minimum version of CMake required to build the native library. 

cmake_minimum_required(VERSION 2.8) 

# Creates and names a library, sets it as either STATIC 
# or SHARED, and provides the relative paths to its source code. 
# You can define multiple libraries, and CMake builds them for you. 
# Gradle automatically packages shared libraries with your APK. 

add_library(# Sets the name of the library. 
      native-lib 

      # Sets the library as a shared library. 
      SHARED 

      # Provides a relative path to your source file(s). 
      src/main/cpp/native-lib.cpp 
      src/main/cpp/NativePlayer.h 
      src/main/cpp/NativePlayer.cpp) 

# Searches for a specified prebuilt library and stores the path as a 
# variable. Because CMake includes system libraries in the search path by 
# default, you only need to specify the name of the public NDK library 
# you want to add. CMake verifies that the library exists before 
# completing its build. 

find_library(# Sets the name of the path variable. 
       log-lib 

       # Specifies the name of the NDK library that 
       # you want CMake to locate. 
       log) 
find_library(png-lib png) 

# Specifies libraries CMake should link to your target library. You 
# can link multiple libraries, such as libraries you define in this 
# build script, prebuilt third-party libraries, or system libraries. 

#avcodec 
#avfilter 
#avformat 
#avutil 
#swresample 
#swscale 

#${ANDROID_ABI} 

message(${ANDROID_ABI}) 
set(FFMPEG_ROOT_DIR src/main/libs/ffmpeg/${ANDROID_ABI}) 

add_library(avcodec STATIC IMPORTED) 
add_library(avformat STATIC IMPORTED) 
add_library(avfilter STATIC IMPORTED) 
add_library(avutil STATIC IMPORTED) 
add_library(swresample STATIC IMPORTED) 
add_library(swscale STATIC IMPORTED) 

#SET_TARGET_PROPERTIES(avcodec PROPERTIES LINKER_LANGUAGE C) 
set_target_properties(avcodec PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/${FFMPEG_ROOT_DIR}/lib/libavcodec.a) 
#SET_TARGET_PROPERTIES(avfilter PROPERTIES LINKER_LANGUAGE C) 
set_target_properties(avfilter PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/${FFMPEG_ROOT_DIR}/lib/libavfilter.a) 
#SET_TARGET_PROPERTIES(avformat PROPERTIES LINKER_LANGUAGE C) 
set_target_properties(avformat PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/${FFMPEG_ROOT_DIR}/lib/libavformat.a) 
#SET_TARGET_PROPERTIES(avutil PROPERTIES LINKER_LANGUAGE C) 
set_target_properties(avutil PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/${FFMPEG_ROOT_DIR}/lib/libavutil.a) 
#SET_TARGET_PROPERTIES(swresample PROPERTIES LINKER_LANGUAGE C) 
set_target_properties(swresample PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/${FFMPEG_ROOT_DIR}/lib/libswresample.a) 
#SET_TARGET_PROPERTIES(swscale PROPERTIES LINKER_LANGUAGE C) 
set_target_properties(swscale PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/${FFMPEG_ROOT_DIR}/lib/libswscale.a) 

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/${FFMPEG_ROOT_DIR}/include) 
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/${FFMPEG_ROOT_DIR}/lib) 
target_link_libraries(# Specifies the target library. 
         native-lib 

         # Links the target library to the log library 
         # included in the NDK. 
         ${log-lib} 
         avcodec 
         avformat 
         #avfilter 
         #swresample 
         #swscale 
         #avutil 
         GLESv2) 

Ich habe .a Dateien in folgenden Orten:

  • %PROJECT_DIR%/app/src/libs/ffmpeg/armeabi-v7a
  • %PROJECT_DIR%/app/src/libs/ffmpeg/armeabi-v7a-neon
  • %PROJECT_DIR%/app/src/libs/ffmpeg/x86

es mir nicht verfehlt, dass die Linker sieht Dateien selbst. (Ich bekomme einen anderen Ausgang, wenn ich sie falsch platziere.)

Antwort

-2

Der Fehler 'Linker Befehl mit Exit Code 1 fehlgeschlagen' wird in der Regel von der detaillierteren Fehler gefolgt. Um weitere Details zu finden, klicken Sie in Xcode auf den Fehler unter Buildtime und wählen Sie Reveal in Log. Dies sollte Ihnen einen zusätzlichen Hinweis geben. Ohne einen spezifischen Fehler ist es nicht möglich zu wissen, wo das Problem liegt.

Verwandte Themen