使用 GCC 4.0 构建 Boost 1.57.0:ld:无法映射文件,errno=22

Building Boost 1.57.0 with GCC 4.0: ld: can't map file, errno=22

我正在尝试在 mac 上使用 gcc 4.0 构建 boost 1.57.0。我首先找到了 this website, but I got a number of linker errors when I tried that. I then found this question,它允许我修复那些链接器错误,但我仍然遇到更多我无法解决的问题。这是演示问题的增强构建输出的片段。

...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++ 命令有问题,但我不知道是什么。有谁知道如何解决这个问题?

链接器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

相反。