Qt Creator:体系结构x86_64的未定义符号 [英] Qt Creator: Undefined symbols for architecture x86_64
问题描述
我在Qt Creator中有一个程序,可以在Windows机器上编译并正常运行.但是,当我尝试在Mac OS X(10.9)中进行编译时,我收到了以下消息:
I have a program in Qt creator that compiles and runs fine in a Windows machine. But as soon as I tried to compile it in a Mac OS X (10.9) I received these messages:
Undefined symbols for architecture x86_64:
"std::__1::__basic_string_common<true>::__throw_length_error() const", referenced from:
std::__1::enable_if<__is_forward_iterator<char*>::value, void>::type std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init<char*>(char*, char*) in libVolumeSelectorLib.a(NetCDFDataSource.o)
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [UI.app/Contents/MacOS/UI] Error 1
14:38:02: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project VVSIT (kit: Desktop Qt 5.4.0 clang 64bit)
When executing step "Make"
我曾尝试清理并再次编译,以防Windows上构建的某些文件进入Mac,但事实并非如此,问题仍然存在.
I have tried cleaning and compiling again in case some file built on Windows had made it to the Mac, but that is not the case, the problem continues happening.
我检查了这些帖子,但它们的解决方案不起作用:
I've checked these posts but their solutions didn't work:
- QT-creator中架构x86_64的未定义符号
- https://stackoverflow.com/questions/23806544 /undefined-symbols-for-architecture-x86-64-in-qt-creator
- Undefined symbols for architecture x86_64 in QT-creator
- https://stackoverflow.com/questions/23806544/undefined-symbols-for-architecture-x86-64-in-qt-creator
有什么办法解决这个错误吗?
Any idea how to solve this error?
推荐答案
After some research I found this thread: Qt5.1/Qt5.2 + XCode 5.0.2 + Mac OS 10.9 (Mavericks), Can’t link to the libraries
该链接包含对我有用的解决方案,我必须编辑该文件:
That link contains the solution that worked for me, I had to edit the file:
/Applications/Qt/5.4/clang_64/mkspecs/macx-clang/qmake.conf
并更改显示以下内容的行:
And change the line that says:
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
收件人:
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
之后,我清理了项目中的每个子项目,然后再次编译它们,现在一切正常.
After that, I cleaned every subproject in my project, and compiled them again, and all is working fine now.
如果您想知道clang++
所做的更改是什么,那就是将参数-mmacosx-version-min=10.7
更改为-mmacosx-version-min=10.9
.
In case you wonder what does that change in the clang++
do, what it does is to change the parameter -mmacosx-version-min=10.7
to -mmacosx-version-min=10.9
.
这篇关于Qt Creator:体系结构x86_64的未定义符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!