CMake Error: shared library text segment is not shareable

在编译ffmpeg时遇到以下错误

/Users/XXXXX/Alan/MyAndroidPro/FfmpegLib/app/src/main/cpp/libs/x86/lib/libavutil.a -lm -lz -latomic -lm "/Users/XXXXX/AndroidDev/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/libgnustl_static.a" && :
  /Users/XXXXX/AndroidDev/sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/darwin-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld:warning: shared library text segment is not shareable
  /Users/XXXXX/AndroidDev/sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/darwin-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld:error: treating warnings as errors
  clang++: error: linker command failed with exit code 1 (use -v to see invocation)
  ninja: build stopped: subcommand failed. 

解决办法:

在CMakeLists.txt里加入如下一行即可解决:

set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wall -v -Wl,--no-warn-shared-textrel")


必须是上面的这种形式,不能是以下形式
set(CMAKE_SHARED_LINKER_FLAGS " -Wall -v -Wl,--no-warn-shared-textrel")
 ,这种还是不能解决问题,需要带上${CMAKE_SHARED_LINKER_FLAGS};
相当于是增加配置参数,+= 


参考链接:

  https://stackoverflow.com/questions/41958527/warning-shared-library-text-segment-is-not-shareable
  https://stackoverflow.com/questions/19986523/shared-library-text-segment-is-not-shareable
  http://blog.csdn.net/youngchenglie/article/details/75539235


你可能感兴趣的:(C/C++)