gpt4 book ai didi

c++ - 无法在 Centos 7 上构建 32 位库

转载 作者:太空宇宙 更新时间:2023-11-04 11:50:36 25 4
gpt4 key购买 nike

我有 Centos7 Vagrant 盒子,里面有“devtoolset-7”。

我使用“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。第一次使用。

https://www.centos.org/forums/viewtopic.php?t=64011

最佳答案

/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

意味着链接器找到的库与 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,因为这是我在 Google 中搜索时发现的版本,如果您安装了不同的版本,请改用它。

关于c++ - 无法在 Centos 7 上构建 32 位库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56167775/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com