gpt4 book ai didi

c++ - 将 jsoncpp 外部库添加到我的 qt 项目 : (symbol(s) not found for architecture x86_64)

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:21:51 26 4
gpt4 key购买 nike

我正在尝试将 jasoncpp 库添加到我的 C++ qt 项目中。我包含了标题,并链接了(我认为)库,但我得到了这些错误:“找不到体系结构 x86_64 的符号”和“链接器命令失败,退出代码为 1(使用 -v 查看调用)”。

没有找到的符号显然是关于jsoncpp库的符号。

这是我的生成文件:

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

我真的不知道如何进行,所以提前致谢。

最佳答案

如果您使用 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

关于c++ - 将 jsoncpp 外部库添加到我的 qt 项目 : (symbol(s) not found for architecture x86_64),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25025542/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com