繁体   English   中英

未定义的引用`PerformChat(char *,char *,char *,char *,char *)

[英]undefined reference to `PerformChat(char*, char*, char*, char*, char*)

我想在我的程序中使用外部的ChatScript。 文件中它说:

嵌入步骤#1首先,您需要修改`common.h并编译系统。 您需要将所有CS .cpp文件添加到构建列表中。

找到// #define NOMAIN 1并取消注释。 这将允许您将程序编译为主程序,而ChatScript仅作为其附带的例程集合。

但我是Linux的新手,无法理解如何将.cpp文件添加到我的构建列表中? 什么是我的构建列表? 愿有人解释我该怎么办?

我复制了我的项目中main.cpp旁边的ChatScript / SRC目录中存在的所有.cpp和.h以及其他文件夹。

然后我试着运行这段代码:

#include<iostream>
using namespace std;

char* output2;
    unsigned int InitSystem(int argc,char* argv[],char* unchangedPath,char* readonlyPath,char* writablePath);
    void InitStandalone();
    void PerformChat(char* user,char* usee,char* incoming,char* ip,char* output);

    int main()
    {

    PerformChat(NULL,NULL,"hi",NULL,output2);

    cout<<output2;

        return 0;
    }

但我收到此错误消息:

undefined reference to `PerformChat(char*, char*, char*, char*, char*)

然后我确实将所有头文件包含到我的程序中并删除了这行代码: void PerformChat(char* user,char* usee,char* incoming,char* ip,char* output);

#include<iostream>

#include "common.h"
#include "common1.h"
#include "constructCode.h"
#include "cs_ev.h"
#include "csocket.h"
#include "dictionaryMore.h"
#include "dictionarySystem.h"
#include "english.h"
#include "evserver.h"
#include "factSystem.h"
#include "functionExecute.h"
#include "infer.h"
#include "jsmn.h"
#include "json.h"
#include "mainSystem.h"
#include "markSystem.h"
#include "mongodb.h"
#include "mprintf.h"
#include "multi.h"
#include "my_sql.h"
#include "os.h"
#include "outputSystem.h"
#include "patternSystem.h"
#include "postgres.h"
#include "privatesrc.h"
#include "scriptCompile.h"
#include "spellcheck.h"
#include "systemVariables.h"
#include "tagger.h"
#include "testing.h"
#include "textUtilities.h"
#include "tokenSystem.h"
#include "topicSystem.h"
#include "userCache.h"
#include "userSystem.h"
#include "variableSystem.h"

using namespace std;

char* output2;
    unsigned int InitSystem(int argc,char* argv[],char* unchangedPath,char* readonlyPath,char* writablePath);
    void InitStandalone();
    void PerformChat(char* user,char* usee,char* incoming,char* ip,char* output);

    int main()
    {

    PerformChat(NULL,NULL,"hi",NULL,output2);

    cout<<output2;

        return 0;
    }

但新错误说:

error: conflicting declaration of C function ‘int main()'

您必须在项目中包含所有chatscript SRC文件才能获得要编译的PerformChat函数。 但很快ChatScript也将发布库编译。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM