Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to compile and test a simple code with ChatScript program.As the tutorial says here: [^]

Quote:

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.
Embedding Step #2 To embed CS within a client, you need to perform two calls. To call these routines, your code will need a

predeclaration of these routines. The first is InitSystem(int argc, char * argv[],char* unchangedPath, char* readablePath, char* writeablePath, USERFILESYSTEM* userfiles) where you pass in
various command line parameters to control things like logging or
memory usage. Only the first two parameters are required, the
remainder being optional and defaulted to NULL.

The second call is the actual workhorse... int PerformChat(char* user, char* usee, char* incoming,char* ip,char* output);

PerformChat is told the user name, the bot name (usee), the incoming
message, the ip address, and where to put the output. The user string
is the user's id. Since this is an embedded app, there will likely be
only one user ever, so this can be hardcoded to anything you want. It
will show up in the log file, and if you upload logs for later
analysis, you will prefer this be unique in some way – a phone id or
whatever.

IP is like the user string, a form of identification that appears in
the log. It may be null or the null string, since the user id will
probably be sufficient. The usee is the name of the chatbot to talk
with. This usually can be defaulted to the null string if you only
have one bot in the system. Incoming is the message from the user. The
first time you start up a session, this should be a null string to
inform the system a conversation is starting. Thereafter, you would
just pass across the user input. Output is the buffer where ChatScript
puts out the response.


Also tutorial says:


Quote:


To call these routines, your code will need a predeclaration of these
routines. Just copy the routine declarations from ChatScript and put
at the start of your file, e.g.,

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




This is my test code written within a file named `main.cpp' :


#include <iostream>
#include "common.h"

using namespace std;


int main(int argc, char * argv[])
{
char* input="hi";
char* output;
char * userID="one";

InitSystem (0, NULL);
void InitStandalone();

PerformChat("one","Harry",input,NULL,output);

cout<<output;

    return 0;
}


What I have tried:

But when I try to compile my program by this command:

g++ -std=c++11 main.cpp constructCode.cpp csocket.cpp dictionarySystem.cpp english.cpp englishTagger.cpp evserver.cpp factSystem.cpp functionExecute.cpp infer.cpp javascript.cpp jsmn.cpp json.cpp mainSystem.cpp markSystem.cpp mysql.cpp os.cpp outputSystem.cpp patternSystem.cpp postgres.cpp privatesrc.cpp scriptCompile.cpp secure.cpp spellcheck.cpp systemVariables.cpp tagger.cpp testing.cpp textUtilities.cpp tokenSystem.cpp topicSystem.cpp userCache.cpp userSystem.cpp variableSystem.cpp -o myprogram


It gives me a bunch off errors that I want to know it's because of my wrong aproach or ChatScript bugs?

                                             ^
/tmp/ccCmIdeq.o: In function `LaunchClient(void*)':
csocket.cpp:(.text+0x4821): undefined reference to `pthread_create'
/tmp/ccCmIdeq.o: In function `InternetServer()':
csocket.cpp:(.text+0x4a01): undefined reference to `pthread_create'
csocket.cpp:(.text+0x4a1f): undefined reference to `pthread_create'
csocket.cpp:(.text+0x4a38): undefined reference to `pthread_join'
/tmp/cco3ht5X.o: In function `GetRemoteFileCode(char*)':
functionExecute.cpp:(.text+0x1acda): undefined reference to `MongoInit(char*)'
functionExecute.cpp:(.text+0x1ada5): undefined reference to `mongoGetDocument(char*, char*, int, bool)'
functionExecute.cpp:(.text+0x1aded): undefined reference to `MongoClose(char*)'
/tmp/cco3ht5X.o:(.data+0xfe8): undefined reference to `MongoInit(char*)'
/tmp/cco3ht5X.o:(.data+0x1008): undefined reference to `MongoClose(char*)'
/tmp/cco3ht5X.o:(.data+0x1028): undefined reference to `mongoInsertDocument(char*)'
/tmp/cco3ht5X.o:(.data+0x1048): undefined reference to `mongoDeleteDocument(char*)'
/tmp/cco3ht5X.o:(.data+0x1068): undefined reference to `mongoFindDocument(char*)'
/tmp/ccMiZBIj.o: In function `RunJavaScript(char*, char*, unsigned int)':
javascript.cpp:(.text+0xd2): undefined reference to `duk_create_heap'
javascript.cpp:(.text+0x12a): undefined reference to `duk_create_heap'
javascript.cpp:(.text+0x52d): undefined reference to `duk_push_string_file_raw'
javascript.cpp:(.text+0x546): undefined reference to `duk_push_string'
javascript.cpp:(.text+0x564): undefined reference to `duk_eval_raw'
javascript.cpp:(.text+0x584): undefined reference to `duk_push_string_file_raw'
javascript.cpp:(.text+0x59d): undefined reference to `duk_push_string'
javascript.cpp:(.text+0x5bb): undefined reference to `duk_compile_raw'
javascript.cpp:(.text+0x5ca): undefined reference to `duk_pop'
javascript.cpp:(.text+0x5f1): undefined reference to `duk_push_string'
javascript.cpp:(.text+0x611): undefined reference to `duk_eval_raw'
javascript.cpp:(.text+0x627): undefined reference to `duk_push_string'
javascript.cpp:(.text+0x647): undefined reference to `duk_compile_raw'
javascript.cpp:(.text+0x656): undefined reference to `duk_pop'
javascript.cpp:(.text+0x674): undefined reference to `duk_push_global_object'
javascript.cpp:(.text+0x68f): undefined reference to `duk_get_prop_string'
javascript.cpp:(.text+0x6ad): undefined reference to `duk_pop'
javascript.cpp:(.text+0x743): undefined reference to `duk_pop'
javascript.cpp:(.text+0x75b): undefined reference to `duk_pop'
javascript.cpp:(.text+0x7cd): undefined reference to `duk_push_string'
javascript.cpp:(.text+0x853): undefined reference to `duk_push_int'
javascript.cpp:(.text+0x8c1): undefined reference to `duk_push_number'
javascript.cpp:(.text+0x908): undefined reference to `duk_pop'
javascript.cpp:(.text+0x920): undefined reference to `duk_pop'
javascript.cpp:(.text+0x94b): undefined reference to `duk_pcall'
javascript.cpp:(.text+0x96d): undefined reference to `duk_safe_to_lstring'
javascript.cpp:(.text+0x98e): undefined reference to `duk_pop'
javascript.cpp:(.text+0x9d7): undefined reference to `duk_safe_to_lstring'
javascript.cpp:(.text+0xa80): undefined reference to `duk_safe_to_lstring'
javascript.cpp:(.text+0xac8): undefined reference to `duk_safe_to_lstring'
javascript.cpp:(.text+0xaec): undefined reference to `duk_pop'
/tmp/ccMiZBIj.o: In function `DeletePermanentJavaScript()':
javascript.cpp:(.text+0xb35): undefined reference to `duk_destroy_heap'
/tmp/ccMiZBIj.o: In function `DeleteTransientJavaScript()':
javascript.cpp:(.text+0xb56): undefined reference to `duk_destroy_heap'
/tmp/ccaAkAWG.o: In function `CurlShutdown()':
json.cpp:(.text+0x1863): undefined reference to `curl_global_cleanup'
/tmp/ccaAkAWG.o: In function `InitCurl()':
json.cpp:(.text+0x1882): undefined reference to `curl_global_init'
/tmp/ccaAkAWG.o: In function `UrlEncodePiece(char*)':
json.cpp:(.text+0x18b5): undefined reference to `curl_easy_init'
json.cpp:(.text+0x1902): undefined reference to `curl_easy_escape'
json.cpp:(.text+0x193a): undefined reference to `curl_free'
json.cpp:(.text+0x1946): undefined reference to `curl_easy_cleanup'
/tmp/ccaAkAWG.o: In function `encodeSegment(char**, char*, char*, void*)':
json.cpp:(.text+0x1a05): undefined reference to `curl_easy_escape'
json.cpp:(.text+0x1a28): undefined reference to `curl_free'
/tmp/ccaAkAWG.o: In function `JSONOpenCode(char*)':
json.cpp:(.text+0x236d): undefined reference to `curl_easy_init'
json.cpp:(.text+0x255e): undefined reference to `curl_easy_setopt'
json.cpp:(.text+0x257e): undefined reference to `curl_easy_setopt'
json.cpp:(.text+0x25a5): undefined reference to `curl_easy_setopt'
json.cpp:(.text+0x25c5): undefined reference to `curl_easy_setopt'
json.cpp:(.text+0x25ec): undefined reference to `curl_easy_setopt'
/tmp/ccaAkAWG.o:json.cpp:(.text+0x260c): more undefined references to `curl_easy_setopt' follow
/tmp/ccaAkAWG.o: In function `JSONOpenCode(char*)':
json.cpp:(.text+0x2620): undefined reference to `curl_slist_append'
json.cpp:(.text+0x2991): undefined reference to `curl_slist_append'
json.cpp:(.text+0x2bc2): undefined reference to `curl_easy_setopt'
json.cpp:(.text+0x2c28): undefined reference to `curl_easy_setopt'
json.cpp:(.text+0x2c8a): undefined reference to `curl_easy_setopt'
json.cpp:(.text+0x2cf7): undefined reference to `curl_easy_setopt'
json.cpp:(.text+0x2d26): undefined reference to `curl_easy_setopt'
/tmp/ccaAkAWG.o:json.cpp:(.text+0x2d53): more undefined references to `curl_easy_setopt' follow
/tmp/ccaAkAWG.o: In function `JSONOpenCode(char*)':
json.cpp:(.text+0x2ea7): undefined reference to `curl_easy_perform'
json.cpp:(.text+0x2ecb): undefined reference to `curl_easy_getinfo'
json.cpp:(.text+0x31cf): undefined reference to `curl_slist_free_all'
json.cpp:(.text+0x31de): undefined reference to `curl_easy_cleanup'
/tmp/ccHKeYzU.o: In function `CreateSystem()':
mainSystem.cpp:(.text+0x10a5): undefined reference to `mongodbparams'
mainSystem.cpp:(.text+0x10b5): undefined reference to `mongodbparams'
/tmp/ccHKeYzU.o: In function `ProcessArgument(char*)':
mainSystem.cpp:(.text+0x2154): undefined reference to `mongodbparams'
/tmp/ccHKeYzU.o: In function `InitSystem(int, char**, char*, char*, char*, USERFILESYSTEM*, void (*)(char*), void (*)(char*))':
mainSystem.cpp:(.text+0x27a1): undefined reference to `mongodbparams'
mainSystem.cpp:(.text+0x31de): undefined reference to `mongodbparams'
/tmp/ccHKeYzU.o:mainSystem.cpp:(.text+0x31e7): more undefined references to `mongodbparams' follow
/tmp/ccHKeYzU.o: In function `InitSystem(int, char**, char*, char*, char*, USERFILESYSTEM*, void (*)(char*), void (*)(char*))':
mainSystem.cpp:(.text+0x31ec): undefined reference to `MongoSystemInit(char*)'
/tmp/ccHKeYzU.o: In function `PartiallyCloseSystem()':
mainSystem.cpp:(.text+0x328e): undefined reference to `MongoSystemRestart()'
/tmp/ccHKeYzU.o: In function `CloseSystem()':
mainSystem.cpp:(.text+0x32a9): undefined reference to `MongoSystemShutdown()'
/tmp/ccHKeYzU.o: In function `Restart()':
mainSystem.cpp:(.text+0x5f7f): undefined reference to `mongodbparams'
mainSystem.cpp:(.text+0x5f88): undefined reference to `mongodbparams'
mainSystem.cpp:(.text+0x5f8d): undefined reference to `MongoSystemInit(char*)'
/tmp/cc5qQNdp.o: In function `mysqlUserRead(void*, unsigned long, unsigned long, _IO_FILE*)':
mysql.cpp:(.text+0xe5): undefined reference to `mysql_stmt_init'
mysql.cpp:(.text+0x10c): undefined reference to `mysql_error'
mysql.cpp:(.text+0x14e): undefined reference to `mysql_stmt_prepare'
mysql.cpp:(.text+0x16b): undefined reference to `mysql_stmt_error'
mysql.cpp:(.text+0x1fe): undefined reference to `mysql_stmt_bind_param'
mysql.cpp:(.text+0x21b): undefined reference to `mysql_stmt_error'
mysql.cpp:(.text+0x241): undefined reference to `mysql_stmt_execute'
mysql.cpp:(.text+0x25e): undefined reference to `mysql_stmt_error'
mysql.cpp:(.text+0x284): undefined reference to `mysql_stmt_store_result'
mysql.cpp:(.text+0x2a1): undefined reference to `mysql_stmt_error'
mysql.cpp:(.text+0x2c7): undefined reference to `mysql_stmt_num_rows'
mysql.cpp:(.text+0x360): undefined reference to `mysql_stmt_bind_result'
mysql.cpp:(.text+0x37d): undefined reference to `mysql_stmt_error'
mysql.cpp:(.text+0x3a3): undefined reference to `mysql_stmt_fetch'
mysql.cpp:(.text+0x3ea): undefined reference to `mysql_stmt_error'
mysql.cpp:(.text+0x420): undefined reference to `mysql_stmt_error'
/tmp/cc5qQNdp.o: In function `mysqlUserWrite(void const*, unsigned long, unsigned long, _IO_FILE*)':
mysql.cpp:(.text+0x56f): undefined reference to `mysql_stmt_init'
mysql.cpp:(.text+0x596): undefined reference to `mysql_error'
mysql.cpp:(.text+0x5d8): undefined reference to `mysql_stmt_prepare'
mysql.cpp:(.text+0x5f5): undefined reference to `mysql_stmt_error'
mysql.cpp:(.text+0x6cb): undefined reference to `mysql_stmt_bind_param'
mysql.cpp:(.text+0x6e8): undefined reference to `mysql_stmt_error'
mysql.cpp:(.text+0x719): undefined reference to `mysql_stmt_execute'
mysql.cpp:(.text+0x731): undefined reference to `mysql_stmt_error'
mysql.cpp:(.text+0x747): undefined reference to `mysql_stmt_errno'
mysql.cpp:(.text+0x784): undefined reference to `mysql_stmt_affected_rows'
mysql.cpp:(.text+0x7c0): undefined reference to `mysql_stmt_init'
mysql.cpp:(.text+0x7e7): undefined reference to `mysql_error'
mysql.cpp:(.text+0x829): undefined reference to `mysql_stmt_prepare'
mysql.cpp:(.text+0x846): undefined reference to `mysql_stmt_error'
mysql.cpp:(.text+0x91c): undefined reference to `mysql_stmt_bind_param'
mysql.cpp:(.text+0x939): undefined reference to `mysql_stmt_error'
mysql.cpp:(.text+0x95f): undefined reference to `mysql_stmt_execute'
mysql.cpp:(.text+0x97c): undefined reference to `mysql_stmt_error'
mysql.cpp:(.text+0x9a2): undefined reference to `mysql_stmt_affected_rows'
mysql.cpp:(.text+0x9c7): undefined reference to `mysql_stmt_error'
/tmp/cc5qQNdp.o: In function `MySQLUserFilesCode()':
mysql.cpp:(.text+0xa09): undefined reference to `mysql_init'
mysql.cpp:(.text+0xa66): undefined reference to `mysql_real_connect'
mysql.cpp:(.text+0xa91): undefined reference to `mysql_error'
/tmp/cc5qQNdp.o: In function `MySQLInitCode(char*)':
mysql.cpp:(.text+0xb45): undefined reference to `mysql_init'
mysql.cpp:(.text+0xb72): undefined reference to `mysql_real_connect'
mysql.cpp:(.text+0xb8c): undefined reference to `mysql_error'
mysql.cpp:(.text+0xbc3): undefined reference to `mysql_query'
mysql.cpp:(.text+0xbd8): undefined reference to `mysql_error'
mysql.cpp:(.text+0xc0a): undefined reference to `mysql_use_result'
mysql.cpp:(.text+0xc24): undefined reference to `mysql_fetch_row'
mysql.cpp:(.text+0xc5b): undefined reference to `mysql_free_result'
mysql.cpp:(.text+0xc67): undefined reference to `mysql_close'
/tmp/cc9CRv1C.o: In function `PostgresShutDown()':
postgres.cpp:(.text+0x1b): undefined reference to `PQfinish'
/tmp/cc9CRv1C.o: In function `DBInitCode(char*)':
postgres.cpp:(.text+0x249): undefined reference to `PQconnectdb'
postgres.cpp:(.text+0x25f): undefined reference to `PQstatus'
postgres.cpp:(.text+0x27b): undefined reference to `PQerrorMessage'
/tmp/cc9CRv1C.o: In function `pguserRead(void*, unsigned long, unsigned long, _IO_FILE*)':
postgres.cpp:(.text+0x750): undefined reference to `PQexecParams'
postgres.cpp:(.text+0x764): undefined reference to `PQresultStatus'
postgres.cpp:(.text+0x785): undefined reference to `PQclear'
postgres.cpp:(.text+0x7ad): undefined reference to `PQntuples'
postgres.cpp:(.text+0x7d8): undefined reference to `PQgetvalue'
postgres.cpp:(.text+0x7fa): undefined reference to `PQclear'
/tmp/cc9CRv1C.o: In function `pguserWrite(void const*, unsigned long, unsigned long, _IO_FILE*)':
postgres.cpp:(.text+0x9c9): undefined reference to `PQexecParams'
postgres.cpp:(.text+0x9dd): undefined reference to `PQresultStatus'
postgres.cpp:(.text+0x9ec): undefined reference to `PQclear'
postgres.cpp:(.text+0xa27): undefined reference to `PQexecParams'
postgres.cpp:(.text+0xa3b): undefined reference to `PQresultStatus'
postgres.cpp:(.text+0xa4a): undefined reference to `PQclear'
/tmp/cc9CRv1C.o: In function `PGUserFilesCode()':
postgres.cpp:(.text+0xb32): undefined reference to `PQconnectdb'
postgres.cpp:(.text+0xb48): undefined reference to `PQstatus'
postgres.cpp:(.text+0xbb3): undefined reference to `PQconnectdb'
postgres.cpp:(.text+0xbc9): undefined reference to `PQstatus'
postgres.cpp:(.text+0xc14): undefined reference to `PQexec'
postgres.cpp:(.text+0xc2a): undefined reference to `PQresultStatus'
postgres.cpp:(.text+0xc5a): undefined reference to `PQerrorMessage'
postgres.cpp:(.text+0xc70): undefined reference to `PQstatus'
postgres.cpp:(.text+0xcce): undefined reference to `PQconnectdb'
postgres.cpp:(.text+0xce4): undefined reference to `PQstatus'
postgres.cpp:(.text+0xd8f): undefined reference to `PQexec'
postgres.cpp:(.text+0xda5): undefined reference to `PQresultStatus'
postgres.cpp:(.text+0xdd5): undefined reference to `PQerrorMessage'
/tmp/cc9CRv1C.o: In function `DBExecuteCode(char*)':
postgres.cpp:(.text+0x1133): undefined reference to `PQexec'
postgres.cpp:(.text+0x1149): undefined reference to `PQresultStatus'
postgres.cpp:(.text+0x117d): undefined reference to `PQerrorMessage'
postgres.cpp:(.text+0x120f): undefined reference to `PQclear'
postgres.cpp:(.text+0x127f): undefined reference to `PQntuples'
postgres.cpp:(.text+0x1294): undefined reference to `PQnfields'
postgres.cpp:(.text+0x12fb): undefined reference to `PQftype'
postgres.cpp:(.text+0x134a): undefined reference to `PQgetvalue'
postgres.cpp:(.text+0x138a): undefined reference to `PQclear'
postgres.cpp:(.text+0x16ab): undefined reference to `PQclear'
collect2: error: ld returned 1 exit status
Posted
Updated 24-Oct-17 21:34pm
v3
Comments
Richard MacCutchan 25-Oct-17 3:47am    
You forgot to add all the external library names to your linker options for gcc to link the object files.

1 solution

You need to go back to where you got the tutorial from: either you are missing important include files, or you are using the wrong compiler, or you just don't have all the source code.

We can't tell - we don't even know where you got this from, so we can't even begin to help you! Talk to the authors: they wrote it, they should know how to fix it.
 
Share this answer
 
Comments
Member 13376650 25-Oct-17 3:36am    
Sorry, I edited the post and added the link of tutorial/project on github!
I asked many times from the author and he couldn't help me!
OriginalGriff 25-Oct-17 4:08am    
If the author can't help you then:
1) He didn't write it and has as little idea how it works as you do.
2) It's never worked, and he doesn't know why.

Either way, chuck it in the f*ckit bucket, and move on - find a better example of what you want that at least starts to work "out of the box". If you try to work with something that won't even compile before you start modifying it, then you are seriously wasting your time even thinking of using it.

If you went to the dealer to buy a car, and he offered you one that was in pieces "but everything is there, won't take you more than a day to assemble it" would you hand over your cash or move on to the dealer down the road?
Member 13376650 25-Oct-17 4:22am    
Dear OriginalGriff, i know it works and it's the winner of Leobner prise for chat bots. But I don't know why I can not work with!
I asked from author here : https://github.com/bwilcox-1234/ChatScript/issues/173 But couldn't solve the problem!

But you right...this is the last day I will try for it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900