未找到架构x86_64的JsonCpp符号 我是C++的新手,用来解析C++对象到JSON,反之亦然。但是,下面的代码不断给出错误,如下所示: Undefined symbols for architecture x86_64: "Json::Value::Value(Json::ValueType)", referenced from: Account::toJson() in Account.o "Json::Value::Value(int)", referenced from: Account::toJson() in Account.o "Json::Value::~Value()", referenced from: Account::toJson() in Account.o ld: symbol(s) not found for architecture x86_64

未找到架构x86_64的JsonCpp符号 我是C++的新手,用来解析C++对象到JSON,反之亦然。但是,下面的代码不断给出错误,如下所示: Undefined symbols for architecture x86_64: "Json::Value::Value(Json::ValueType)", referenced from: Account::toJson() in Account.o "Json::Value::Value(int)", referenced from: Account::toJson() in Account.o "Json::Value::~Value()", referenced from: Account::toJson() in Account.o ld: symbol(s) not found for architecture x86_64,c++,json,C++,Json,以下是Account.cpp代码: #include <cassert> #include "json/json.h" #include "Account.h" Account::Account() { id_ = 0; balance_ = 0; income_ = 0; } Account::Account(int id, int balance, int income, std::string date) { id_ = id; b

以下是Account.cpp代码:

#include <cassert>
#include "json/json.h"
#include "Account.h"

Account::Account() {
    id_ = 0;
    balance_ = 0;
    income_ = 0;
}

Account::Account(int id, int balance, int income, std::string date) {

    id_ = id;
    balance_ = balance;
    income_ = income;
    date_ = date;
}

Account::~Account() {

}

// Getters and setters omitted

Json::Value Account::toJson() {
    Json::Value value(Json::objectValue);
    value["id"] = id_;
    value["balance"] = balance_;
    value["income"] = income_;
    value["date"] = date_;

    return value;
}
#包括
#包括“json/json.h”
#包括“Account.h”
Account::Account(){
id=0;
平衡=0;
收入=0;
}
账户::账户(整数id、整数余额、整数收入、标准::字符串日期){
id=id;
平衡=平衡;
收入=收入;
日期=日期;
}
账户::~Account(){
}
//省略了getter和setter
Json::Value Account::toJson(){
Json::Value(Json::objectValue);
值[“id”]=id;
值[“余额”]=余额;
价值[“收入”]=收入;
值[“日期”]=日期;
返回值;
}

你找到答案了吗?