【问题标题】:Building Boost 1.57.0 with GCC 4.0: ld: can't map file, errno=22使用 GCC 4.0 构建 Boost 1.57.0:ld:无法映射文件,errno=22
【发布时间】:2017-05-02 16:55:17
【问题描述】:

我正在尝试在 mac 上使用 gcc 4.0 构建 boost 1.57.0。我首先找到了this website,但是当我尝试这样做时,我遇到了一些链接器错误。然后我找到了this question,它允许我修复那些链接器错误,但我仍然得到更多我无法解决的问题。这是演示该问题的 boost 构建输出的 sn-p。

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

【问题讨论】:

    标签: macos gcc boost linker gcc4


    【解决方案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
    

    改为。

    【讨论】:

      猜你喜欢
      • 2011-07-15
      • 1970-01-01
      • 2014-11-21
      • 2014-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多