About ChaiScript

ChaiScript is the first and only scripting language designed from the ground up with C++ compatibility and modern design in mind. It is an ECMAScript-inspired, embedded functional-like language.

ChaiScript is licensed under the BSD license.

Download

Due to an increased release schedule, and the nature of ChaiScript being a header-only library, binary releases will be made less often. Previous releases can be found on github.

Version: 4.2.0 Released: 12/1/2012
(Requires Boost)
Source (tar.bz2)
Source (zip)

Version: 5.2.0 Released: 12/1/2012
(Requires C++11 Compiler)
Source (tar.bz2)
Source (zip)

CHAISCRIPT_NO_THREADS flag error

When chaiscript compiled with define CHAISCRIPT_NO_THREADS program throw exeption:

terminate called after throwing an instance of 'chaiscript::exception::load_module_error'
  what():  Unable to find module: chaiscript_stdlib Errors: libchaiscript_stdlib.dll: cannot open shared object file: No such file or directory; libchaiscript_stdlib.so: cannot open shared object file: No such file or directory; libchaiscript_stdlib: cannot open shared object file: No such file or directory; chaiscript_stdlib.dll: cannot open shared object file: No such file or directory; chaiscript_stdlib.so: cannot open shared object file: No such file or directory; chaiscript_stdlib: cannot open shared object file: No such file or directory; chai/libchaiscript_stdlib.dll: cannot open shared object file: No such file or directory; chai/libchaiscript_stdlib.so: cannot open shared object file: No such file or directory; chai/libchaiscript_stdlib: cannot open shared object file: No such file or directory; chai/chaiscript_stdlib.dll: cannot open shared object file: No such file or directory; chai/chaiscript_stdlib.so: cannot open shared object file: No such file or directory; chai/chaiscript_stdlib: cannot open shared object file: No such file or directory

I'm on arch linux i686

No stdlib in docs?

I stumbled across this thread while having a similiar problem with chaiscript. I rechecked with the documentation but could not find any hint on compiling the chai stdlib. You might want to add that to the getting started section and the minimal runable program example
(I am using MingW32, g++ 4.7.0)
I also have been wondering why you compile with gcc instead of g++ (since chaiscript is a c++ library)
EDIT: I tried compiling

#include <chaiscript/chaiscript_stdlib.hpp>
#include <chaiscript/chaiscript.hpp>
 
int main()
{
	chaiscript::ChaiScript cscr(chaiscript::Std_Lib::library());
	cscr.eval("print(\"Test\")");
 
	return 0;
}

with

g++ Main.cpp -Iinc -Llib -std=c++11 -ldl -DCHAISCRIPT_NO_THREADS

and I get

inc/chaiscript/dispatchkit/../chaiscript_threading.hpp:14:66: Anmerkung: #pragma message: ChaiScript is compiling without thread safety.
d:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/as.exe: C:\Users\Master\AppData\Local\Temp\ccMbkZwn.o: too many sections (39050)
C:\Users\Master\AppData\Local\Temp\ccpdmTtE.s: Assembler messages:
C:\Users\Master\AppData\Local\Temp\ccpdmTtE.s: Fatal error: can't write C:\Users\Master\AppData\Local\Temp\ccMbkZwn.o: File too big
d:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/as.exe: C:\Users\Master\AppData\Local\Temp\ccMbkZwn.o: too many sections (39050)
C:\Users\Master\AppData\Local\Temp\ccpdmTtE.s: Fatal error: can't close C:\Users\Master\AppData\Local\Temp\ccMbkZwn.o: File too big

Any instructions on compiling the stdlib/modules for the runtime by hand?

Yes, sorry the docs still

Yes, sorry the docs still need to be updated for the C++11 port. The ability to compile in the Std_Lib, as you are showing, or to load it dynamically was added to reduce compile times.

I don't know what you would be seeing a "File too big" error. Your code looks correct. If you use the cmake generated makefile, does it work? Does the command line look any different? I haven't tried compiling on mingw in quite some time and I've not yet tried g++ 4.7 at all

Also, where am I using gcc instead of g++? If that's in a document somewhere please point it out, I would like to correct it.

Can you link me to the mingw distribution you are using and I will try to compile it myself?

Thank you,
Jason

I have no cmake available

I have no cmake available (basically all I can work with is make). I use the official MinGW distribution http://www.mingw.org/ 32 Bit latest install from repositories.

As for the gcc usage, in your documentation: http://chaiscript.com/doxygen/index.html
The command line for compiling the first sample is

gcc main.cpp -I/path/to/chaiscript/headers -ldl -lboost_threads

EDIT:
I managed to compile the code with

g++ -std=c++11 Main.cpp src\chaiscript_stdlib.cpp -ldl -L. -Iinclude -DCHAISCRIPT_NO_THREADS -O3
#include <chaiscript/chaiscript_stdlib.hpp>
#include <chaiscript/chaiscript.hpp>
 
int main()
{
	chaiscript::ChaiScript cscr(chaiscript::Std_Lib::library());
	cscr.eval("print(\"Test\")");
 
	return 0;
}

(I had to download libdl.a for mingw, for some reason its not packed with all the other libraries)
The -O3 option seems to do the trick (source: http://permalink.gmane.org/gmane.comp.parsers.spirit.general/24423)
I guess this is really a problem with gas

And now if you excuse me, I have a new script language to mess around with

Great, I'm glad you got it

Great, I'm glad you got it working. Sorry I had not yet had time to set up a mingw dev environment myself.

It's unfortunate you cannot make a debug build, just in case you needed it later.

You need to either make sure

You need to either make sure the stdlib is also compiled with CHAISCRIPT_NO_THREADS or compile the stdlib into the application.

If you are installing the ubuntu package then the stdlib is compiled with threads enabled. If you are installing it yourself, there shouldn't be any problem.

If you want to build the library into your application so that there are no extra files to ship, do this:

#include <chaiscript/chaiscript_stdlib.hpp>
#include <chaiscript/chaiscript.hpp>
 
int main()
{
  // Build and pass the stdlib we want to use to the constructor
  chaiscript::ChaiScript chai(chaiscript::Std_Lib::library());
}

The downside is that it takes a bit longer to compile.

-Jason

I try to build it by my self.

I try to build it by my self. I clone repo, then unset multithreading:

option(MULTITHREAD_SUPPORT_ENABLED "Multithreaded Support Enabled" FALSE)

than "cmake ." from chaiscript root catalog, then "make". After build i start "chai" file and get this error =(
I'm not on Ubuntu =) I'm on ArchLinux =) There is an unsupported user packet for chaiscript, but it have the same problem

There are two possible

There are two possible explanations. One is that the stdlib is not build built for some reason the other is that it cannot be found by the runtime linker.

I'm not sure what to say, I've double checked the building both with and without multithreading support and have had no problem on either 4.0 or 5.0 releases.

Can you use it with threading enabled until I get the chance to check against Arch? I don't currently have it set up.

-Jason

Sorry for the long absence. I

Sorry for the long absence. I can not remember which version I used, but I decided to also check everything again.
I downloaded version 5.0.0 and try to compile test program (interpreter) with and without multithreaded support option and run it. In both cases, no errors =) I'm sorry for your time. I'll let you know if the error is repeated =)

Glad to know it's

Glad to know it's working!

Jason

Unfortunately, I still had

Unfortunately, I still had problems. I will try to describe them.
1. I download zip archive from GitHub with latest version of ChaiScript
2. Extract the archive in "$PROJECT_FOLDER/chaiscript"
3. Do "cd chaiscript", "cmake ." and "make"

After that, in chaiscript folder appears binary "chai". It works fine(!).

Then I write some code in $PROJECT_FOLDER/main.cpp :

#include <chaiscript/chaiscript.hpp>
 
using namespace chaiscript;
 
int main()
{
    ChaiScript context;
    context.eval("print(\"hello\")");
    return 0;
}

and build it. I use QtCreator to build. On output:

g++ -c -pipe -std=c++0x -march=i686 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -Wall -W  -I/usr/share/qt/mkspecs/linux-g++ -I../dummy -Ilib/chaiscript/include -I../dummy -I. -o main.o ../dummy/main.cpp
g++ -Wl,-O1,--sort-common,--as-needed,-z,relro -Wl,-O1 -o dummy main.o     -ldl -lpthread 

it build programm called "dummy" in $PROJECT_FOLDER/../.dummy-release

next if i try to exec binary i have error like in first message of this topic.
I tried to run from different locations:
$PROJECT_FOLDER
$PROJECT_FOLDER/chaiscript
$PROJECT_FOLDER/../.dummy-release
But the problem did not disappear...

Then i check chaiscript folder. I found "libreflection.so", "libstl_extra.so", "libtest_module.so", but no "libchaiscript_stdlib.so" or some other .so files.
In CMakeList.txt i found references to flection and stl_extra libraries, but nothing about chaiscript_stdlib or something similar.

Please, help me. How to build chaiscript_stdlib library?

By the way: Why not distribute everything in a library with headers like others? =)

Support ChaiScript by sharing it with your friends: