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

551 Views Asked by At

I want to use ChatScript externally in my program. In the documents it says:

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.

But I am newbie in Linux and can’t understand how to add .cpp files to my build list? 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.

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);

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

There are 1 best solutions below

6
On

You would have to include all the chatscript SRC files in your project to get the function PerformChat to compile. But shortly ChatScript will release with library compilations as well.