我想在我的程序中外部使用ChatScript。在文档中,它说:
嵌入步骤1首先,您需要修改
common.h and compile the system. You need to add all the CS .cpp files to your build list. Find the// #定义NOMAIN 1‘并取消注释。这将允许您将您的程序编译为主程序,而ChatScript仅作为与其配套的例程的集合。
但是我是Linux的新手,不知道如何将.cpp文件添加到我的构建列表中?我的建造清单是什么?有人能解释一下我应该做什么吗?
在我的项目中,除了我的.cpp和.h目录之外,我还复制了ChatScript/SRC目录中的所有main.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()'发布于 2017-10-15 16:01:57
您必须在项目中包含所有聊天脚本SRC文件,才能编译函数PerformChat。但是不久,ChatScript也将发布库编译。
https://stackoverflow.com/questions/46749399
复制相似问题