arm-linux-androidabi/bin/ld:致命错误:-soname:必须采用非空参数

arm-linux-androideabi/bin/ld: fatal error: -soname: must take a non-empty argument

本文关键字:参数 -soname bin ld 致命错误 arm-linux-androidabi      更新时间:2023-10-16

我正在与cmake android交叉编译gdcm,它一直到编译结束,但最后我得到了以下错误。在编译库时,你们如何在cmakegui或cmake中设置-soname,这样我们就可以避免下面的错误。

/opt/android/android-ndk-r10c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-    androideabi/bin/ld: fatal error: -soname: must take a non-empty argument
collect2: error: ld returned 1 exit status
make[2]: *** [/home/likewise-open/SLKTECHLABS/kirtan.patel/Desktop/GDCM/GDCMSource/libs/armeabi-v7a/libgdcmjni.so] Error 1
make[1]: *** [Wrapping/Java/CMakeFiles/gdcmjni.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
/home/kirtan.patel/Desktop/GDCM/GDCMSource/Source/MediaStorageAndFileFormat/gdcmImageWriter.h:36: Warning 822: Covariant return     types not supported in Java. Proxy method will return gdcm::Pixmap const &.
/home/kirtan.patel/Desktop/GDCM/GDCMSource/Source/MediaStorageAndFileFormat/gdcmImageCodec.h:45: Warning 473: Returning a     pointer or reference in a director method is not recommended.

正如Romanski所指出的,CMake版本3.2和3.0由于UseSWIG.cmake文件的不同而具有不同的行为。在3.2中,默认启用的NO_SONAME属性看起来会在android构建中引发冲突,从而产生无效的链接选项-Wl,-soname,和空的TARGET_SONAME。

有两种方法可以修复3.2版本的构建

  1. string(REPLACE "<CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME>" "" CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE}")完全消除了断开的链接选项
  2. set_target_properties(${MY_TARGET} PROPERTIES NO_SONAME OFF)用正确的so名称修复断开的链接选项