编译 Boost 时在 OS X 上的"ld:未知选项:-soname"

“ld: unknown option: -soname” on OS X when compiling Boost

本文关键字:quot Boost 未知 选项 -soname ld 时在 上的 编译 OS      更新时间:2023-10-16

我想从不同平台上的源代码构建 Boost。我已经能够在 linux 上做到这一点(在 docker 映像上(。我也能够在我自己的计算机上执行此操作(Mac OS X 10.13 Xcode 9.4.1(,但是当我在 circleci 图像上尝试同样的事情(使用 Xcode 9.4.1(时,它失败并显示以下错误:

这可能不是很相关,但我使用 cGet 来解决我的依赖项,包括 Boost。在这种情况下,cGet 只是下载 Boost 并运行 b2 命令。这是输出:

我明确尝试使用 GNU 编译器和链接器,正如您在输出中看到的那样,工具集正在正确传递给b2命令,但我遇到了--soname名称问题。我知道它可以通过使用install_name来修复,但这是 b2 必须修复的问题,对吧?

cGet Github 页面

Extracting archive /Users/distiller/project/cget/cget/build/tmp-00245e52aeba4b19b5a676b97304b3b5/boost_1_68_0.tar.bz2 ...
-- The C compiler identification is AppleClang 9.1.0.9020039
-- The CXX compiler identification is AppleClang 9.1.0.9020039
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/gcc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
using clang-linux : cget : "/Library/Developer/CommandLineTools/usr/bin/c++" : 
<rc>
<archiver>/Library/Developer/CommandLineTools/usr/bin/ar
<ranlib>/Library/Developer/CommandLineTools/usr/bin/ranlib
<include>/Users/distiller/project/cget/include
<library-path>/Users/distiller/project/cget/lib
;
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/distiller/project/cget/cget/build/tmp-00245e52aeba4b19b5a676b97304b3b5/build
Scanning dependencies of target bootstrap
-n Bootstrapping the build engine with toolset darwin... 
engine/bin.macosxx86_64/b2
Bootstrapping is done. To build and install, run:
./b2 install --prefix=<DIR>
[  0%] Built target bootstrap
Scanning dependencies of target boost
[100%] /Users/distiller/project/cget/cget/build/tmp-00245e52aeba4b19b5a676b97304b3b5/boost_1_68_0/tools/build/b2 -q -j 4 --ignore-site-config --user-config=/Users/distiller/project/cget/cget/build/tmp-00245e52aeba4b19b5a676b97304b3b5/build/user-config.jam --build-dir=/Users/distiller/project/cget/cget/build/tmp-00245e52aeba4b19b5a676b97304b3b5/build/build address-model=64 link=shared target-os=darwin threadapi=pthread threading=multi toolset=clang-linux-cget variant=release  cxxflags=-std=c++11 -std=c++11  --layout=system --disable-icu --with-filesystem --prefix=/Users/distiller/project/cget/cget/pkg/boost/install --exec-prefix=/Users/distiller/project/cget/cget/pkg/boost/install/bin --libdir=/Users/distiller/project/cget/cget/pkg/boost/install/lib --includedir=/Users/distiller/project/cget/cget/pkg/boost/install/include
Performing configuration checks
- default address-model    : 64-bit
- default architecture     : x86
Building the Boost C++ Libraries.

- symlinks supported       : yes
Component configuration:
.
.
.
- filesystem               : building
.
.
.
...patience...
...found 701 targets...
...updating 28 targets...
link.mklink boost/chrono/stopwatches.hpp
mklink-or-dir boost/chrono/stopwatches
clang-linux.compile.c++.without-pth /Users/distiller/project/cget/cget/build/tmp-00245e52aeba4b19b5a676b97304b3b5/build/build/boost/bin.v2/libs/filesystem/build/clang-linux-cget/release/threading-multi/codecvt_error_category.o
clang-linux.compile.c++.without-pth /Users/distiller/project/cget/cget/build/tmp-00245e52aeba4b19b5a676b97304b3b5/build/build/boost/bin.v2/libs/system/build/clang-linux-cget/release/threading-multi/error_code.o
clang-linux.link.dll /Users/distiller/project/cget/cget/build/tmp-00245e52aeba4b19b5a676b97304b3b5/build/build/boost/bin.v2/libs/system/build/clang-linux-cget/release/threading-multi/libboost_system.dylib
ld: unknown option: -soname
clang: error: linker command failed with exit code 1 (use -v to see invocation)
"/Library/Developer/CommandLineTools/usr/bin/c++"   -o "/Users/distiller/project/cget/cget/build/tmp-00245e52aeba4b19b5a676b97304b3b5/build/build/boost/bin.v2/libs/system/build/clang-linux-cget/release/threading-multi/libboost_system.dylib" -Wl,-soname -Wl,libboost_system.dylib -shared  "/Users/distiller/project/cget/cget/build/tmp-00245e52aeba4b19b5a676b97304b3b5/build/build/boost/bin.v2/libs/system/build/clang-linux-cget/release/threading-multi/error_code.o"       -fPIC -m64 
...failed clang-linux.link.dll /Users/distiller/project/cget/cget/build/tmp-00245e52aeba4b19b5a676b97304b3b5/build/build/boost/bin.v2/libs/system/build/clang-linux-cget/release/threading-multi/libboost_system.dylib...
...skipped <pstage/lib>libboost_system.dylib for lack of <p/Users/distiller/project/cget/cget/build/tmp-00245e52aeba4b19b5a676b97304b3b5/build/build/boost/bin.v2/libs/system/build/clang-linux-cget/release/threading-multi>libboost_system.dylib...
clang-linux.compile.c++.without-pth /Users/distiller/project/cget/cget/build/tmp-00245e52aeba4b19b5a676b97304b3b5/build/build/boost/bin.v2/libs/filesystem/build/clang-linux-cget/release/threading-multi/path_traits.o
clang-linux.compile.c++.without-pth /Users/distiller/project/cget/cget/build/tmp-00245e52aeba4b19b5a676b97304b3b5/build/build/boost/bin.v2/libs/filesystem/build/clang-linux-cget/release/threading-multi/path.o
clang-linux.compile.c++.without-pth /Users/distiller/project/cget/cget/build/tmp-00245e52aeba4b19b5a676b97304b3b5/build/build/boost/bin.v2/libs/filesystem/build/clang-linux-cget/release/threading-multi/operations.o
clang-linux.compile.c++.without-pth /Users/distiller/project/cget/cget/build/tmp-00245e52aeba4b19b5a676b97304b3b5/build/build/boost/bin.v2/libs/filesystem/build/clang-linux-cget/release/threading-multi/unique_path.o
...failed updating 1 target...
...skipped 1 target...
...updated 21 targets...
make[2]: *** [CMakeFiles/boost] Error 1
make[1]: *** [CMakeFiles/boost.dir/all] Error 2
make: *** [all] Error 2
Command failed: ['/usr/local/bin/cmake', '--build', '/Users/distiller/project/cget/cget/build/tmp-00245e52aeba4b19b5a676b97304b3b5/build', '--config', 'Release', '--', '-j', '4']
Failed to build package boost
Exited with code 1

工具集应设置为clang-darwin