Xcode / GCC链接问题:文件不是必需的体系结构

时间:2009-01-28 08:30:01

标签: xcode macos gcc g++ linker

我正在尝试将包含boost 1.37和wxwidgets的Windows项目移植到Mac。它编译好了,但链接器给了我一个“文件不是架构ppc所需的架构”错误的libz.1.dylib和相同的消息作为警告其他一些库。我还得到了libz.1.dylib的“重复dylib”警告。

链接器输出如下所示:

使用配置“Debug”构建项目“Gemsweeper Mac”的目标“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平台很新,所以任何帮助都将不胜感激!

谢谢,

阿德里安

4 个答案:

答案 0 :(得分:2)

听起来你需要重新下载或重建Mac的提升。无论你是什么dylib,你都需要这样做。简单来说,您只需要重新安装库。

使用boost你不需要再次重新下载整个内容,源代码本身是多平台的,它只是从平台到平台的二进制文件(lib等)。您可能已经下载了所有源代码,因此您只需要从源代码重建库。 http://www.boost.org/doc/libs/1_37_0/more/getting_started/unix-variants.html为您提供了有关使用bjam构建boost的一些信息。我知道在Windows上他们有预编译的二进制文件,但我在Mac的boost网站上看​​不到任何相关信息。

答案 1 :(得分:2)

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

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

答案 2 :(得分:0)

使用sudo port xxx install + universal帮助卸载并重新安装zlib和libiconv(以及其他十几个依赖库)。感谢您的快速回复! : - )

答案 3 :(得分:0)

你需要定位本机架构,而不是两个......通用'。

涉及将xcode设置为“构建机器的本机架构”,“仅构建活动架构”和“#39;和有效架构'取决于您的xcode版本。但要清理所有可能的建筑变体。

那就是因为使用默认./b2 install的boost只会获得本机架构。

尝试使用./b2 install toolset=intel

重新安装boost

一个可能的(并且未尝试过的)解决方案是两次构建提升。

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

原生./b2 install --prefix=/usr/local/ppc