gpt4 book ai didi

c++ - 对 `PerformChat(char*, char*, char*, char*, char*) 的 undefined reference

转载 作者:太空狗 更新时间:2023-10-29 22:56:50 30 4
gpt4 key购买 nike

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

Embedding Step #1 First, you will need to modify `common.h and compile the system. You need to add all the CS .cpp files to your build list.

Find the // #define NOMAIN 1 and uncomment it. This will allow you to compile your program as the main program and ChatScript merely as a collection of routines to accompany it.

但我是 Linux 新手,不明白如何将 .cpp 文件添加到我的构建列表中?我的构建列表是什么?有人可以解释我应该做什么吗?

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

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

#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()'

最佳答案

您必须在项目中包含所有聊天脚本 SRC 文件,才能编译 PerformChat 函数。但很快 ChatScript 也将与库编译一起发布。

关于c++ - 对 `PerformChat(char*, char*, char*, char*, char*) 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46749399/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com