Xcode / GCC链接问题:文件不符合所需架构

8
我正在尝试将一个包含boost 1.37和wxwidgets的Windows项目移植到Mac。编译可以通过,但链接器会给我一个“文件不符合ppc架构所需”的错误,该错误是针对libz.1.dylib以及其他几个库的警告信息。我还收到了关于libz.1.dylib的“重复dylib”警告。
链接器输出如下:
正在使用“Debug”配置生成“Gemsweeper Mac”项目的目标
检查依赖项
Ld "/Users/adriangrigore/Documents/Gemsweeper Mac/Gemsweeper MacOS/Gemsweeper Mac/build/Debug/Gemsweeper Mac.app/Contents/MacOS/Gemsweeper Mac" normal i386
    cd "/Users/adriangrigore/Documents/Gemsweeper Mac/Gemsweeper MacOS/Gemsweeper Mac"
    setenv MACOSX_DEPLOYMENT_TARGET 10.4
    /Developer/usr/bin/g++-4.0 -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk "-L/Users/adriangrigore/Documents/Gemsweeper Mac/Gemsweeper MacOS/Gemsweeper Mac/build/Debug" -L/Developer/SDKs/MacOSX10.4u.sdk/usr/local/lib -L/opt/local/lib "-F/Users/adriangrigore/Documents/Gemsweeper Mac/Gemsweeper MacOS/Gemsweeper Mac/build/Debug" -F/Users/adriangrigore/Library/Frameworks -F/Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks -filelist "/Users/adriangrigore/Documents/Gemsweeper Mac/Gemsweeper MacOS/Gemsweeper Mac/build/Gemsweeper Mac.build/Debug/Gemsweeper Mac.build/Objects-normal/i386/Gemsweeper Mac.LinkFileList" -mmacosx-version-min=10.4 -L/opt/local/lib -L/Users/adriangrigore/wxwidgets-manual/wxMac-2.8.9/lib /opt/local/lib/libboost_system-mt.a /opt/local/lib/libboost_program_options-mt.a /opt/local/lib/libboost_thread-mt.a -arch ppc -arch i386 -framework IOKit -framework Carbon -framework Cocoa -framework System -framework QuickTime -framework OpenGL -framework AGL /Users/adriangrigore/wxwidgets-manual/wxMac-2.8.9/lib/libwx_mac-2.8.a -framework WebKit -lwxexpat-2.8 -lwxtiff-2.8 -lwxjpeg-2.8 -lwxpng-2.8 -lz -lpthread -liconv -framework SDL -framework Cocoa -o "/Users/adriangrigore/Documents/Gemsweeper Mac/Gemsweeper MacOS/Gemsweeper Mac/build/Debug/Gemsweeper Mac.app/Contents/MacOS/Gemsweeper Mac"
ld warning: in /Users/adriangrigore/Documents/Gemsweeper Mac/Gemsweeper MacOS/Gemsweeper Mac/build/Gemsweeper Mac.build/Debug/Gemsweeper Mac.build/Objects-normal/i386/main.o, file is not of required architecture
ld warning: in /Users/adriangrigore/Documents/Gemsweeper Mac/Gemsweeper MacOS/Gemsweeper Mac/build/Gemsweeper Mac.build/Debug/Gemsweeper Mac.build/Objects-normal/i386/variousfunctions-xcode.o, file is not of required architecture
ld warning: in /Users/adriangrigore/Documents/Gemsweeper Mac/Gemsweeper MacOS/Gemsweeper Mac/build/Gemsweeper Mac.build/Debug/Gemsweeper Mac.build/Objects-normal/i386/ParticleLayers.o, file is not of required architecture
ld warning: in /Users/adriangrigore/Documents/Gemsweeper Mac/Gemsweeper MacOS/Gemsweeper Mac/build/Gemsweeper Mac.build/Debug/Gemsweeper Mac.build/Objects-normal/i386/SDLMain.o, file is not of required architecture
ld warning: in /opt/local/lib/libboost_system-mt.a, file is not of required architecture
ld warning: in /opt/local/lib/libboost_program_options-mt.a, file is not of required architecture
ld warning: in /opt/local/lib/libboost_thread-mt.a, file is not of required architecture
ld warning: in /opt/local/lib/libz.dylib, file is not of required architecture
ld warning: in /opt/local/lib/libiconv.dylib, file is not of required architecture
ld: in /opt/local/lib/libz.1.dylib, file is not of required architecture for architecture ppc
collect2: ld returned 1 exit status
ld warning: duplicate dylib /opt/local/lib/libz.1.dylib
ld warning: duplicate dylib /opt/local/lib/libiconv.2.dylib

我对Mac平台还比较陌生,希望能得到帮助!

谢谢,

Adrian

4个回答

2
听起来你需要重新下载或重建Mac的boost。无论是什么dylib,你都需要这样做。简单地说,你只需要重新安装库。
对于boost,你不需要重新下载整个东西,源代码本身是多平台的,只有二进制文件(libs等)从平台到平台会发生变化。很可能你已经下载了所有的源代码,所以你只需要从源代码重新构建库。 http://www.boost.org/doc/libs/1_37_0/more/getting_started/unix-variants.html 提供了一些使用bjam构建boost的信息。我知道在Windows上他们有预编译的二进制文件,但我在boost网站上没有看到任何关于Mac的信息。

2

从您收到的消息来看,大多数Gemsweeper Mac和libboost只使用ppc作为架构进行编译。您应该配置Xcode以生成通用二进制文件,并可能通过MacPorts重新编译libboost。最近的MacPorts有一个“universal”目标,可以帮助,但如果您不打算在ppc上运行它,则只需重新编译即可。

您似乎还需要重新编译zlib和libiconv。


0

你需要以本地架构为目标,而不是“通用”的架构。

这涉及到根据你的xcode版本设置xcode为“本地构建架构”,“仅构建活动架构”和“有效架构”,并清除所有可能存在的架构变体。

这是因为使用默认的./b2 install命令只能获得本地架构。

尝试使用./b2 install toolset=intel重新安装boost。

一种可能的(但未经尝试的)解决方案是将boost构建两次。

Intel ./b2 install --prefix=/usr/local/x64 toolset=intel

本地 ./b2 install --prefix=/usr/local/ppc


0
卸载并重新安装zlib和libiconv(以及其他十几个依赖库),使用sudo port xxx install +universal命令可以解决问题。感谢您的快速回复!:-)

4年就像猎豹一样快。实际上,这是为了未来使用asio的其他人而做的。我遇到了同样的问题,花了我一天甚至更长时间才解决这个令人困惑的问题。现在又出现了SSL错误。你尝试过SSL服务器吗? - Gabe Rainbow

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接