在连接阶段诊断"contains undefined reference for architecture"
Diagnosing "contains undefined reference for architecture" at linking phase
我正在尝试使用qmake/qt在MacOSX上构建一个x86_64应用程序。我能够在QT4中编译,但不能在QT5中编译。
无论如何,在运行qmake生成我的makefile etc:之后
qmake-recursive-spec macx clang app.pro CONFIG+="释放静态"
然后当我运行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_66库参与该过程。
使用file
命令进行检查后,构建中的所有.o文件都是Mach-O 64-bit object x86_64
。
对于我尝试引用的所有库(例如libcrypto):
Non-fat file: ../lib/libcrypto.a is architecture: x86_64
当然,所有的mac框架库都支持32/64位。
有人对我如何进一步调试有什么建议吗?
玩了一整天,找到了。
链接抱怨的方法有这样的:
qt_mac_execute_apple_script
qt5中不存在此方法。
此外,在问题文件的前面,我有这样的:
extern bool qt_mac_execute_apple_script(const QString &script, AEDesc *ret);
如果我对这些行进行注释,错误就会消失。
因此,基本上,对于一个丢失的符号来说,这是一个非常糟糕的编译器错误——因为编译器不够好,无法指出模糊的体系结构声明之外的实际问题;可能会变得更糟,因为我正在构建与extern静态耦合的应用程序。
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- Visual Studio Code "undefined reference to `WinMain@16'"
- 使用 MATLAB 编码器生成C++代码:编译错误"undefined reference to `rgb2gray_tbb_real64'"
- "Undefined class"作为is_base_of的论据
- 为什么创建友元类的实例会导致"undefined reference to"错误?
- Tensorflow c++ api undefined reference to 'tflite::D efaultErrorReporter()'
- VSCode C/C++ Intellisense issue: Undefined identifiers (Linu
- 与卡特琳娜一起卷曲C++失败并得到"Undefined symbols for architecture x86_64"
- "Undefined symbols for architecture x86_64" 在 SDL 2 (macOS) 中
- 为什么在使用 SDL2 时仍然收到'undefined reference'链接器错误?
- 从 C 可执行文件加载动态库时收到错误C++"undefined symbol"
- 为什么即使在定义之后仍存在"Identifier is undefined error "?
- OpenCV undefined reference to 'cv::imread(cv::String const&, int)'
- 为什么当我在 C 程序中链接静态库时会"undefined symbol"?
- Vector, assign() function Undefined Behavior
- OpenCV imwrite 函数导致'undefined symbol'
- Libcurl c++ "undefined reference to" (Windows/MinGW/g++)
- 尝试使用 extern "C" 调用 C 中的C++方法,得到"undefined reference to"对象的链接器错误
- build error : undefined reference to `yyFlexLexer::yyFlexLex
- 在连接阶段诊断"contains undefined reference for architecture"