C++;控制台应用程序未在macOS上的Xcode 9.3中编译 我正在使用XCODE(9.3)在MAC上开发C++控制台(命令行)应用程序。它的编译和运行都很好,但后来我做了一些代码更改,之后它显示了一些奇怪的编译时错误。喜欢 “/clang:-1:链接器命令失败,退出代码为1(使用-v查看调用)” 架构x86_64的未定义符号: “LJCPPBL_CORE::LJCPPBL::Initialize(std::_1::basic_string)”,引用自: _主音中的主音 “LJCPPBL_核心::LJCPPBL::GetShortestPath(标准::基本字符串,标准::基本字符串,浮点*)”,引用自: _主音中的主音 “LJCPPBL_CORE::LJCPPBL::GetJson()”,引用自: _主音中的主音 ld:找不到架构x86_64的符号 叮当声:错误:链接器命令失败,退出代码为1(使用-v查看调用)

C++;控制台应用程序未在macOS上的Xcode 9.3中编译 我正在使用XCODE(9.3)在MAC上开发C++控制台(命令行)应用程序。它的编译和运行都很好,但后来我做了一些代码更改,之后它显示了一些奇怪的编译时错误。喜欢 “/clang:-1:链接器命令失败,退出代码为1(使用-v查看调用)” 架构x86_64的未定义符号: “LJCPPBL_CORE::LJCPPBL::Initialize(std::_1::basic_string)”,引用自: _主音中的主音 “LJCPPBL_核心::LJCPPBL::GetShortestPath(标准::基本字符串,标准::基本字符串,浮点*)”,引用自: _主音中的主音 “LJCPPBL_CORE::LJCPPBL::GetJson()”,引用自: _主音中的主音 ld:找不到架构x86_64的符号 叮当声:错误:链接器命令失败,退出代码为1(使用-v查看调用),c++,xcode,static-libraries,linker-errors,undefined-reference,C++,Xcode,Static Libraries,Linker Errors,Undefined Reference,上面的文字显示在日志中。在分析日志之后,我知道它的“LJCPPBL”类的显示方法没有定义,但我已经正确地定义了这些方法,并且头文件和cpp文件都包含在项目中。请帮帮我 这是LJCPPBL头文件“ljcpbl.hpp” \ifndef ljcpbl\u水电站 #定义LJCPPBL_水电站 #包括 #包括“./Models/Models.hpp” #包括 #包括 使用名称空间std; 使用名称空间LJCPPBL_模型; 名称空间LJCPPBL_核心{ 类ljcpbl { public:静态void初

上面的文字显示在日志中。在分析日志之后,我知道它的“LJCPPBL”类的显示方法没有定义,但我已经正确地定义了这些方法,并且头文件和cpp文件都包含在项目中。请帮帮我

这是LJCPPBL头文件“ljcpbl.hpp”

\ifndef ljcpbl\u水电站
#定义LJCPPBL_水电站
#包括
#包括“./Models/Models.hpp”
#包括
#包括
使用名称空间std;
使用名称空间LJCPPBL_模型;
名称空间LJCPPBL_核心{
类ljcpbl
{
public:静态void初始化(字符串clientapkey);
public:静态字符串GetJson();
public:静态void SetJson(字符串strJson);
public:static list GetDestinationsList();
public:static list GetShortestPath(字符串源、字符串目标、float*costOfPath);
};
}
#endif/*LJCPPBL_水电站*/
这是LJCPPBL头文件“LJCPPBL.cpp”的实现

#包括
#包括“ljcpbl.hpp”
#包括“./Models/Models.hpp”
#包括“./DAL/DataAccess.cpp”
#包括“./Plugins/JsonParser/json.hpp”
#包括“SPC.cpp”
#包括“GlobalValues.cpp”
#包括
使用名称空间std;
使用名称空间ljcpbl_CORE;
使用名称空间ljcpbl_DAL;
名称空间LJCPPBL_核心{
void ljcpbl::初始化(字符串clientapkey){
自动全局值=新全局值();
ljcpblglobalvalues=*globalValues;
ljcpblglobalvalues.clientapkey=clientapkey;
}
字符串LJCPPBL::GetJson()
{
ljcpblapidal*objDAL=新的ljcpblapidal();
字符串mapPointsAndPathJson=objDAL->GetMapsAndPointsJSON();
字符串mapDestinationJSON=objDAL->GetMapDestinationsJSON();
json jsonObj={{“MapPointsAndPathJSON”,MapPointsAndPathJSON},{“MapDestinationJSON”,MapDestinationJSON};
返回jsonObj.dump();
}
void ljcpbl::SetJson(字符串strJson)
{
}
列表LJCPPBL::GetDestinationsList()
{
ljcpblapidal*objDAL=新的ljcpblapidal();
返回objDAL->GetDestinations();
}
列表LJCPPBL::GetShortestPath(字符串源、字符串目标、浮点*costOfPath)
{
返回SPC::GetShortestPath(源、目标、costOfPath);
}
}
//#恩迪夫
这是我的主.cpp文件

#include <iostream>
#include "Models/Models.hpp"
#include "Core/LJCPPBL.hpp"

using namespace std;
using namespace LJCPPBL_Models;
using namespace LJCPPBL_CORE;

int main(int argc, const char * argv[]) {

    //Destination* ds = new Destination();
    LJCPPBL::Initialize("APiKEY"); 
    string jsonstring = LJCPPBL::GetJson();
    string source = "SourceQuickLink";
    string destination = "DestinationQuickLink";
    float pathCost = -2;
    auto lstShortestPath = LJCPPBL::GetShortestPath(source, destination, &pathCost);

        if(lstShortestPath.size() == 1){
            cout << "\n No Path Exists From " << source << " To " << destination << "\n\n";
        }
        else{
            cout << "\nShortest Path From " << source << " To " << destination << " Is:\n\n";
            for (Point & point : lstShortestPath)
            {
                cout << point.Identifier << " (" << point.X << ", " << point.Y << ") ";

                if(point.Identifier != destination)
                    cout << " -> ";
                else
                    cout << "\n\nPath Cost Is: " << pathCost;
            }

            cout << "\n\nPath Cost Is: " << pathCost;
        }

    return 0;
}
#包括
#包括“Models/Models.hpp”
#包括“核心/LJCPPBL.hpp”
使用名称空间std;
使用名称空间LJCPPBL_模型;
使用名称空间ljcpbl_CORE;
int main(int argc,const char*argv[]{
//目的地*ds=新目的地();
ljcpbl::初始化(“APiKEY”);
字符串jsonstring=ljcpbl::GetJson();
字符串source=“SourceQuickLink”;
字符串destination=“DestinationQuickLink”;
浮动路径成本=-2;
auto lstShortestPath=ljcpbl::GetShortestPath(源、目标和路径成本);
if(lstShortestPath.size()==1){

您能否解释一下静态库是如何创建的,并验证您的
main
目标是否与所述静态库链接?可能与@Botje重复抱歉,我的项目不是一个静态库,而是一个控制台(命令行工具)申请,我已经更新了question@MikeKinghan感谢您的回复,但我已经访问了这些链接,但没有找到任何适合我的答案。请帮助我。我是c++新手,如果您需要帮助,您肯定需要共享您的项目设置,因为您的
LJCPBBL.cpp
似乎没有被编译和/或链接到
main
。您能否解释静态库是如何创建的,并验证您的
main
目标是否与所述静态库链接?可能与@Botje重复抱歉,我的项目不是静态库,而是控制台(命令行工具)申请,我已经更新了question@MikeKinghan感谢您的回复,但我已经访问了这些链接,但没有找到任何适合我的答案。请帮助我。我是c++新手,如果您需要帮助,您肯定需要共享您的项目设置,因为您的
LJCPBBL.cpp
似乎没有被编译和/或链接到
main
#ifndef LJCPPBL_hpp
#define LJCPPBL_hpp

#include <iostream>
#include "../Models/Models.hpp"
#include <list>
#include <string.h>

using namespace std;
using namespace LJCPPBL_Models;

namespace LJCPPBL_CORE {

 class LJCPPBL
    {
        public: static void Initialize(string clientAPIKEY);
        public: static string GetJson();
        public: static void SetJson(string strJson);
        public: static list<Destination> GetDestinationsList();
        public: static list<Point> GetShortestPath(string source, string destination, float* costOfPath);
    };
}

#endif /* LJCPPBL_hpp */
#include <iostream>
#include "LJCPPBL.hpp"
#include "../Models/Models.hpp"
#include "../DAL/DataAccess.cpp"
#include "../Plugins/JsonParser/json.hpp"
#include "SPC.cpp"
#include "GlobalValues.cpp"
#include <list>

using namespace std;
using namespace LJCPPBL_CORE;
using namespace LJCPPBL_DAL;

namespace  LJCPPBL_CORE{
void LJCPPBL::Initialize(string clientAPIKEY){
        auto globalValues = new GlobalValues();
        LJCPPBLGlobalValues = *globalValues;
        LJCPPBLGlobalValues.ClientAPIKey = clientAPIKEY;
    }

    string LJCPPBL::GetJson()
    {
        LJCPPBLAPIDAL* objDAL = new LJCPPBLAPIDAL();
        string mapPointsAndPathJson = objDAL -> GetMapsAndPointsJSON();
        string mapDestinationJSON = objDAL -> GetMapDestinationsJSON();
        json jsonObj = {{"MapPointsAndPathJSON", mapPointsAndPathJson}, {"MapDestinationJSON", mapDestinationJSON} };
        return jsonObj.dump();
    }

    void LJCPPBL::SetJson(string strJson)
    {

    }

    list<Destination> LJCPPBL::GetDestinationsList()
    {
         LJCPPBLAPIDAL* objDAL = new LJCPPBLAPIDAL();
        return objDAL -> GetDestinations();
    }

    list<Point> LJCPPBL::GetShortestPath(string source, string destination, float* costOfPath)
    {
        return SPC::GetShortestPath(source, destination, costOfPath);
    }
}
//#endif
#include <iostream>
#include "Models/Models.hpp"
#include "Core/LJCPPBL.hpp"

using namespace std;
using namespace LJCPPBL_Models;
using namespace LJCPPBL_CORE;

int main(int argc, const char * argv[]) {

    //Destination* ds = new Destination();
    LJCPPBL::Initialize("APiKEY"); 
    string jsonstring = LJCPPBL::GetJson();
    string source = "SourceQuickLink";
    string destination = "DestinationQuickLink";
    float pathCost = -2;
    auto lstShortestPath = LJCPPBL::GetShortestPath(source, destination, &pathCost);

        if(lstShortestPath.size() == 1){
            cout << "\n No Path Exists From " << source << " To " << destination << "\n\n";
        }
        else{
            cout << "\nShortest Path From " << source << " To " << destination << " Is:\n\n";
            for (Point & point : lstShortestPath)
            {
                cout << point.Identifier << " (" << point.X << ", " << point.Y << ") ";

                if(point.Identifier != destination)
                    cout << " -> ";
                else
                    cout << "\n\nPath Cost Is: " << pathCost;
            }

            cout << "\n\nPath Cost Is: " << pathCost;
        }

    return 0;
}