AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Using CHatscript as a library
 
 

Hi,

I managed to build chatscript in Visual Studio 2010.
Next i defined the DLL tag in common.h:

#define DLL 

Now, after building I get a chatscript.lib in adition to the chatscript.exe.

Now i wrote the following Program wich uses this .lib file:

#include "stdafx.h"
#include <iostream>
typedef FILE* (*UserFileCreate)(const charname);
typedef FILE* (*UserFileOpen)(const charname);
typedef int (*UserFileClose)(FILE*);
typedef size_t (*UserFileRead)(voidbuffer,size_t sizesize_t countFILEfile);
typedef size_t (*UserFileWrite)(const voidbuffer,size_t sizesize_t countFILEfile);
typedef size_t (*UserFileSize)(FILEfile);

typedef struct USERFILESYSTEM //  how to access user topic data
{
 UserFileCreate userCreate
;  // "wb" implied
 
UserFileOpen userOpen
 
UserFileClose userClose;
 
UserFileRead userRead;
 
UserFileWrite userWrite;
 
UserFileSize userSize;

} USERFILESYSTEM;

 
extern "C" int InitSystem(int argcchar argv[],charunchangedPath NULL,charreadonlyPath NULLcharwritablePath NULLUSERFILESYSTEMuserfiles NULL);
int _tmain(int argc_TCHARargv[])
{
 int ret 
InitSystem(0,NULL);
 
std::cout << "init:" << ret << std::endl;
 
system("pause");
 return 
0;

Now the weird part:

This new program chatScriptDummy.exe asks for the chatscript.exe. Afterwards it crashes.

If I open the chatscript.lib with the dependency walker it tells “No DOS or PE signature found. This is not a valid 32-bit or 64-bit windows module”.
I just scanned all documentation files and I only found the “ChatScript External Communications.pdf” helpful for my case. But it seems to be outdated, at least the InitSystem definition is not the same as in the sources. Also it doesn´t say anything about building a library. I also searched this forum and found a few threads talking about libraries, but nowhere i found a documentation how to do it.

Either I havent found one or it is so simple that you probably wouldn´t need one, because obviously peope managed to build a chatscript library.

Can you guys tell me where my mistake is?

Thank you,
Tobi

 

 
  [ # 1 ]

Hi, Tobias.

Somewhere here in the forums, there is at least one thread that relates to building ChatScript as a DLL. You may find something useful within that thread. Try using the search page for “chatscript dll” (no quotes, of course) to see what you can find. wink

 

 
  [ # 2 ]

Dependency Walker only processes “executable” code, i.e. .exe and .dll files.


Is your intention to build a DLL, or to statically link CS into your own .exe?

If the former then you will need to create a VS Configuration where the General | Configuration type is Dynamic Library. Typically your program would then use LoadLibrary() to load up the DLL when needed and GetProcAddress() to find the actual address of the exported functions.

If statically linking then you should just need to direct your VS configuration to pull in the CS library as an additional dependency for the linker.


Therefore it all comes down to what you’ve set up in your VS Configurations for the project.

 

 
  [ # 3 ]
Dave Morton - Jan 21, 2016:

Hi, Tobias.

Somewhere here in the forums, there is at least one thread that relates to building ChatScript as a DLL. You may find something useful within that thread. Try using the search page for “chatscript dll” (no quotes, of course) to see what you can find. wink

As I said, I already searched the forum, but i couldn´t find such basics instructions as I need.

Andy Heydon - Jan 21, 2016:

Is your intention to build a DLL, or to statically link CS into your own .exe?

[...]

If statically linking then you should just need to direct your VS configuration to pull in the CS library as an additional dependency for the linker

Jeah, I´ve already included the .lib into my project settings.

 

 
  login or register to react