将jsoncpp外部库添加到我的qt项目:(找不到架构x86_64的符号)

时间:2014-07-29 21:48:05

标签: c++ qt linker jsoncpp

我试图将jasoncpp库添加到我的C ++ qt项目中。 我包括标题,并链接(我认为)库但我得到这些错误: "找不到架构x86_64"的符号;和"链接器命令失败,退出代码为1(使用-v查看调用)"。

未找到的符号显然与jsoncpp库有关。

这是我的makefile:

QT       += core gui webkitwidgets

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = JsonTest
TEMPLATE = app

SOURCES += main.cpp\
mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/lib/release/ -ljson
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/lib/debug/ -ljson
else:unix: LIBS += -L$$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/lib/ -ljson

INCLUDEPATH += $$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/include
DEPENDPATH += $$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/include

我真的不知道怎么办,所以提前谢谢。

1 个答案:

答案 0 :(得分:1)

如果您使用cmake安装它,请尝试以下命令:

mkdir -p build/debug
cd build/debug
cmake -DCMAKE_BUILD_TYPE=debug -DJSONCPP_LIB_BUILD_STATIC=ON -DJSONCPP_LIB_BUILD_SHARED=OFF -G "Unix Makefiles" ../..
make

更改

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/lib/release/ -ljson
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/lib/debug/ -ljson
else:unix: LIBS += -L$$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/lib/ -ljson

INCLUDEPATH += $$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/include
DEPENDPATH += $$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/include

为此:

unix|win32: LIBS += -ljsoncpp 

并准备使用jsoncpp