【问题标题】:Diagnosing "contains undefined reference for architecture" at linking phase在链接阶段诊断“包含未定义的架构参考”
【发布时间】:2013-08-23 13:28:10
【问题描述】:

我正在尝试使用 qmake/qt 在 MacOSX 上构建 x86_64 应用程序。我能够在 QT4 中编译,但不能在 QT5 中编译。

无论如何,在运行 qmake 生成我的 makefile 等之后:

qmake -recursive -spec macx-clang app.pro CONFIG+='release static'

然后当我运行 make 时,最终我会在这里结束:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -arch x86_64 -Wl,-dead_strip -framework Cocoa -framework Carbon -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.6 -o (...author's note--tons of .o files here...) -L../lib -L../../debug -F/Users/seth/workspace/qt5.1.0//5.1.0/clang_64/lib -lprotobuf -framework Security -framework SecurityInterface -framework ApplicationServices -framework CoreFoundation -lxml2 -lbz2 -lxar -framework ScriptingBridge -L/Users/seth/workspace/qt5.1.0//5.1.0/clang_64/plugins/iconengines -lssl -lcrypto -lz -lFLAC -framework Carbon -framework QtWebKitWidgets -framework QtQuick -framework QtQml -framework QtNetwork -framework QtCore -framework QtGui -framework QtOpenGL -framework QtWidgets -framework QtPrintSupport -framework Cocoa -framework QtWebKit -framework QtSql -framework QtSensors -framework QtSvg -framework QtXml -framework OpenGL -framework AGL

ld: '__ZN3Log16DebugE7QStringS3_' in debug/Log.o contains undefined reference for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

我不明白“架构 x86_64 的未定义参考”是什么意思,这肯定是问题的核心。在阅读了其他一些线程后,有人建议我链接的库不是 x86_64,但在检查和重新检查后,我找不到该过程涉及的任何非 x86_64 库。

在使用file 命令检查后,我构建的所有.o 文件都是Mach-O 64-bit object x86_64

对于我尝试引用的所有库(例如 libcrypto):

Non-fat file: ../lib/libcrypto.a is architecture: x86_64

当然,所有的 mac 框架库都支持 32/64 位。

有人对我如何进一步调试有任何建议吗?

【问题讨论】:

    标签: c++ macos qt linker ld


    【解决方案1】:

    折腾了一天,终于找到了。

    链接抱怨的方法中有这个:

    qt_mac_execute_apple_script

    qt5中不存在此方法。

    另外,在有问题的文件的前面,我有这个:

    extern bool qt_mac_execute_apple_script(const QString &script, AEDesc *ret);

    如果我评论这些行,错误就会消失。

    所以基本上,缺少符号是一个非常糟糕的编译器错误——因为编译器并没有很好地指出实际问题超出了模糊的架构声明;可能会变得更糟,因为我正在构建与外部静态耦合的应用程序。

    【讨论】:

      猜你喜欢
      • 2019-07-24
      • 2016-01-29
      • 2021-06-27
      • 1970-01-01
      • 1970-01-01
      • 2017-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多