我有一个叫“devtoolset-7”的Centos7变量盒。
我使用'CMake‘来构建和编译库。这是CMakeLists.txt文件
set(CMAKE_BUILD_TYPE Release)
include_directories("../Include" "/usr/include/libusb-1.0")
add_library(CXIOInterface SHARED
CXIOInterface.cpp
HidInterface_Linux.cpp
HidDevice_Linux.cpp
../Include/Debug.cpp
app.cpp
CrcLibrary.cpp
ContextFunctions.cpp)
set(PROJECT_LINK_LIBS -ludev -lusb-1.0)
target_link_libraries(CXIOInterface LINK_PUBLIC ${PROJECT_LINK_LIBS})
set(CMAKE_CXX_FLAGS "-m32")当我为64位编译它时,一切都运行得很好。但是当我为32位编译它时,我得到的错误是:
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: skipping incompatible /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/libstdc++_nonshared.a when searching for -lstdc++_nonshared
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: cannot find -lstdc++_nonshared
collect2: error: ld returned 1 exit status
make[2]: *** [CXIOInterface/libCXIOInterface.so] Error 1 你们能帮帮我吗,我不知道该怎么做。
已经有一个链接告诉我安装rpm,但我是ubuntu用户,而不是Centos用户。第一次使用它。
发布于 2019-05-17 05:10:09
搜索/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld:时跳过不兼容的/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/libstdc++_nonshared.a的
-lstdc++_nonshared
意味着链接器找到的库与ABI不兼容,在这种情况下,它与32位不兼容。
发生这种情况的原因是,您缺少了此操作所需的包,就像您添加的链接状态一样。
首先,找出您安装的devtoolset的当前版本:
rpm -qa | grep devtoolset-7从输出中,您应该能够很容易地确定您现在使用的是哪个版本。
然后,尝试运行:
yum install devtoolset-7-libstdc++-devel-7.2.1-1.el7.x86_64.rpm注释:我使用7.2.1-1,因为这是我在谷歌中搜索时发现的版本,如果你安装了不同的版本,请使用它。
https://stackoverflow.com/questions/56167775
复制相似问题