Qt Creator 3.2.2./Mac OSX 10.9.3 Qt Creaator中未定义的符号,在命令行中确定
Qt Creator 3.2.2 / Mac OSX 10.9.3 Undefined symbol in Qt Creator, OK in command line
我遇到了这个问题,链接器由于未定义的符号而失败,而它在命令行中工作得很好。希望你们能帮我解决这个问题。
costesmanager_gui.pro
#-------------------------------------------------
#
# Project created by QtCreator 2014-10-22T14:45:23
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = costesmanager_gui
TEMPLATE = app
SOURCES += main.cpp
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
INCLUDEPATH += /Users/noe/boost_1_56_0
LIBS += -L/Users/noe/costesmanager/gui/costesmanager_gui/lib -lyaml-cpp
INCLUDEPATH += /Users/noe/costesmanager/gui/costesmanager_gui/yaml-cpp/include
命令树输出:
$ tree
.
├── costesmanager_gui.pro
├── costesmanager_gui.pro.user
├── lib
│ └── libyaml-cpp.a
├── main.cpp
├── mainwindow.cpp
├── mainwindow.h
├── mainwindow.ui
├── test.cpp
└── yaml-cpp
...
├── include
│ └── yaml-cpp
...
│ └── yaml.h
...
编译器输出:
Undefined symbols for architecture x86_64:
"YAML::LoadFile(std::string const&)", referenced from:
_main in main.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: *** [costesmanager_gui.app/Contents/MacOS/costesmanager_gui] Error 1
15:50:30: Le processus "/usr/bin/make" s'est terminé avec le code 2.
Erreur lors de la compilation/déploiement du projet costesmanager_gui (kit : Desktop Qt 5.3 clang 64bit)
When executing step "Make"
我的main.cpp文件由一个基本的YAML::LoadFile("foo.bar")组成,并试图显示它。
我尝试创建一个名为YAML::LoadFile()
的test.cpp,然后用以下两个命令编译它(Qt生成相同的+所有包含的东西,我也可以粘贴它):
$ clang++ -c -I/Users/noe/costesmanager/gui/costesmanager_gui/yaml-cpp/include -I /Users/noe/boost_1_56_0 -o test.o test.cpp
$ clang++ test.o -o test -L/Users/noe/costesmanager/gui/costesmanager_gui/lib/ -lyaml-cpp
它是有效的。
我不知道我错过了什么。非常感谢!
编辑:如果你有任何清洁这棵树的建议,我会很高兴。不知道组织这一切的标准方法。
好的,所以解决方案很简单,但很难发现(疯狂的狩猎)。
由于OSX中有两个C++标准库(请参阅此处),我不得不特别告诉编译器使用libc++。
因此我添加了
QMAKE_CXXFLAGS = -stdlib=libc++
LIBS += -stdlib=libc++
到我的.pro文件,现在一切正常!
仍然不知道为什么在命令行上我不必这么做,但是。。。如果有人有线索?
祝大家今天愉快。
相关文章:
- 调试符号中缺少 QObject 类信息(编辑但存在其他 Qt 类)
- Qt QSpinbox在设置范围后接受'+'符号
- Qt C++LNK2019:使用QNetworkAccessManager未解析的外部符号
- 与Qt交叉编译到Raspberry Pi 3B+通讯录(协议缓冲区)-错误符号查找错误
- 检测键按事件 - Qt C++上的插入符号 (^) 键
- Qt Creator项目打破:"找不到建筑x86_64符号"
- QT QT QBYTEARRAY无符号数据类型
- 使用层类时的 QT 未解析外部符号
- VTK / ITK/ QT - 未解决的外部符号错误 (LNK2001)
- QT:尝试在QT中使用Python.h时未定义的符号
- QT创建者:简单程序未解决的外部符号和外部符号错误
- 使用现有C程序编写Qt程序时未找到的符号
- Qt 和 CMake 失败并出现重复的符号
- 部署后的Linux qt应用程序-符号查找错误:libQt5Core.so.5未定义的符号:uncv_getDefaul
- 将Qt项目转换为VC++项目 - 未解析的外部符号
- QT私有API未解决的外部符号
- C 错误:: -1:错误:QT-CREATOR中未找到架构X86_64的符号(S)
- qt项目中未解析的外部符号
- Qt中的非类方法(带有qtcreator)未解析的外部符号
- Qt:找到多个定义的符号