我试图在Mac上使用gcc 4.0构建boost 1.57.0。我首先找到了this website,但是当我尝试这个时,我遇到了一些链接器错误。然后我发现this question允许我修复那些链接器错误,但我仍然得到更多我无法解决的问题。这是一个演示此问题的boost构建输出的片段。
...failed gcc.compile.c++ bin.v2/libs/context/build/gcc-4.0.1/release/threading-multi/unsupported.o...
...skipped <p/boost_1_57_0/lib>libboost_context.dylib for lack of <pbin.v2/libs/context/build/gcc-4.0.1/release/threading-multi>unsupported.o...
gcc.link.dll /boost_1_57_0/lib/libboost_thread.dylib
ld: can't map file, errno=22 file '/System/Library/Frameworks/Python.framework/Versions/2.7/lib' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
"g++" -Wl,"/System/Library/Frameworks/Python.framework/Versions/2.7/lib" -Wl,"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config" -o "/boost_1_57_0/lib/libboost_thread.dylib" -shared "bin.v2/libs/thread/build/gcc-4.0.1/release/threading-multi/pthread/thread.o" "bin.v2/libs/thread/build/gcc-4.0.1/release/threading-multi/pthread/once.o" "bin.v2/libs/thread/build/gcc-4.0.1/release/threading-multi/future.o" "bin.v2/libs/system/build/gcc-4.0.1/release/threading-multi/libboost_system.dylib" "bin.v2/libs/atomic/build/gcc-4.0.1/release/threading-multi/libboost_atomic.dylib"
...failed gcc.link.dll /boost_1_57_0/lib/libboost_thread.dylib...
...skipped <pbin.v2/libs/context/build/gcc-4.0.1/release/threading-multi>libboost_context.dylib for lack of <pbin.v2/libs/context/build/gcc-4.0.1/release/threading-multi>unsupported.o...
...skipped <p/boost_1_57_0/lib>libboost_coroutine.dylib for lack of <pbin.v2/libs/context/build/gcc-4.0.1/release/threading-multi>libboost_context.dylib...
gcc.link.dll /boost_1_57_0/lib/libboost_date_time.dylib
ld: can't map file, errno=22 file '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
"g++" -Wl,"/System/Library/Frameworks/Python.framework/Versions/2.7/lib" -Wl,"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config" -o "/boost_1_57_0/lib/libboost_date_time.dylib" -shared "bin.v2/libs/date_time/build/gcc-4.0.1/release/threading-multi/gregorian/greg_month.o" "bin.v2/libs/date_time/build/gcc-4.0.1/release/threading-multi/gregorian/greg_weekday.o" "bin.v2/libs/date_time/build/gcc-4.0.1/release/threading-multi/gregorian/date_generators.o"
...failed gcc.link.dll /boost_1_57_0/lib/libboost_date_time.dylib...
gcc.link.dll /boost_1_57_0/lib/libboost_filesystem.dylib
ld: can't map file, errno=22 file '/System/Library/Frameworks/Python.framework/Versions/2.7/lib' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我相信g ++命令有问题,但我不知道是什么。有谁知道如何解决这个问题?
答案 0 :(得分:1)
链接器ld
正在被引导相信
/System/Library/Frameworks/Python.framework/Versions/2.7/lib
是必须读取的链接中的输入文件。它不是; 它是一个目录,因此尝试将其作为文件读取失败。
因为你的g++
连接命令的这一点,所以我们会相信这一点:
-Wl,"/System/Library/Frameworks/Python.framework/Versions/2.7/lib"
告诉它。 g++
选项:
-Wl,...
表示:直接传递 ...
到链接器。所以传递路径名
虽然对链接器。 ld
命令行中的任何路径名都被解释
如果没有任何链接器选项的前缀,则为输入文件的名称
另有说明。
同样的错误紧接着:
-Wl,"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config"
您可能希望告诉g++
目录
/System/Library/Frameworks/Python.framework/Versions/2.7/lib
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config
是链接器可以找到链接所需的库的链接。 (至少, 这很可能是你想要的第一个。我不是那么关心的 秒)。
为此,请传递g++
选项:
-L/System/Library/Frameworks/Python.framework/Versions/2.7/lib -L/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config
代替。