简体   繁体   English

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

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

I want to use ChatScript externally in my program. 我想在我的程序中使用外部的ChatScript。 In the documents it says: 文件中它说:

Embedding Step #1 First, you will need to modify `common.h and compile the system. 嵌入步骤#1首先,您需要修改`common.h并编译系统。 You need to add all the CS .cpp files to your build list. 您需要将所有CS .cpp文件添加到构建列表中。

Find the // #define NOMAIN 1 and uncomment it. 找到// #define NOMAIN 1并取消注释。 This will allow you to compile your program as the main program and ChatScript merely as a collection of routines to accompany it. 这将允许您将程序编译为主程序,而ChatScript仅作为其附带的例程集合。

But I am newbie in Linux and can't understand how to add .cpp files to my build list? 但我是Linux的新手,无法理解如何将.cpp文件添加到我的构建列表中? What is my build list? 什么是我的构建列表? May someone explains what do should I do exactly? 愿有人解释我该怎么办?

I did copy all the .cpp and .h and other folders existed inside ChatScript/SRC directory beside my main.cpp in my project. 我复制了我的项目中main.cpp旁边的ChatScript / SRC目录中存在的所有.cpp和.h以及其他文件夹。

Then I tried to run this code: 然后我试着运行这段代码:

#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;
    }

But I get this error message: 但我收到此错误消息:

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

Then I did include all the header files to my program and delete this line of code: void PerformChat(char* user,char* usee,char* incoming,char* ip,char* output); 然后我确实将所有头文件包含到我的程序中并删除了这行代码: 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;
    }

But the new error says: 但新错误说:

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

You would have to include all the chatscript SRC files in your project to get the function PerformChat to compile. 您必须在项目中包含所有chatscript SRC文件才能获得要编译的PerformChat函数。 But shortly ChatScript will release with library compilations as well. 但很快ChatScript也将发布库编译。

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

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