【问题标题】:Building with 32 bit mode on Mac OS X Lion在 Mac OS X Lion 上使用 32 位模式构建
【发布时间】:2012-02-03 00:28:57
【问题描述】:

我尝试使用此命令在 Mac OS X Lion 上编译 LLVM 2.4。

./configure --enable-pic --prefix=/usr/local CC="gcc -arch i386" CXX="g++ -arch i386"

我收到了这个错误。

Undefined symbols for architecture i386:
  "llvm::PATypeHolder::get() const", referenced from:
      llvm::ELFWriter::EmitGlobal(llvm::GlobalVariable*)    in libLLVMCodeGen.a(ELFWriter.o)
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status

这有什么问题?

【问题讨论】:

    标签: macos gcc osx-lion llvm


    【解决方案1】:

    对于交叉编译,configure 喜欢在您提供主机、目标和使用机器元组进行构建时使用它。

    如果你不熟悉你的机器元组是什么,你可以使用

    gcc -dumpmachine
    

    其中,使用 Lion 报告:

    i686-apple-darwin11
    

    请注意,在 Lion x86_64-apple-darwin11 上对 64 位有效。但是,在构建 llvm 时使用它:

    ./configure \
         --enable-pic \
         --prefix=/usr/local \
         --host=i686-apple-darwin11 \
         --target=i686-apple-darwin11 \
         --build=i686-apple-darwin11
    

    应该可以,但您可能需要包含

    --enable-languages=c,c++,obj-c
    --enable-optimized 
    

    您还可以使用“file”和“otool”来验证要链接的库。或者,如果它是您要链接的静态存档(看起来就是这种情况..),我的快速测试是

     ar p somelib.a $(ar t somelib.a | grep \.o | tail -1) | file -
    

    您不会遇到 i386 OSX Lion 盒子,因此为 i386 构建 clang 似乎是不必要的 - 您可能构建 64 位版本(默认选择任何版本),然后当您使用它编译时,您将在 CFLAGS 或 CXXFLAGS 中指定“-m32”或“-m64”以生成正确的对象位深度。

    -n

    【讨论】:

    • 我正在尝试在 i386 OSX Lion 机器上构建一些东西。
    猜你喜欢
    • 2012-01-13
    • 1970-01-01
    • 2012-11-15
    • 1970-01-01
    • 1970-01-01
    • 2012-11-01
    • 2011-11-17
    • 2012-01-10
    • 2011-05-04
    相关资源
    最近更新 更多