Help! I can't compile example



First, I want to thank you very much, you’d create a great lib that we can use C++ as script. You know, I have look for so many years, Lua, python, and others, they can not match me.

I want to use ChaiScript in my app, my app is trading stock and future, so use ChaiScript is very fast and powerful.

But, I meet problems with ChaiScript:

  1. I use C++ Builder XE5 and Visual Studio 2010, when I used 5.3, I was told can’t find “thread” lib. Is it C++ 11? How can I include this lib? I can not find it in C++ Builder XE5 or Visual Studio 2010.

  2. ChaiScript 5.xx and 4.xx , the only different is using lib( C++ 11 and Boost)? So, do you want to support C++11 in the future, and will not support Boost anymore?

Best regards



I try to use boost lib in Visual Studio with ChaiScript 4.3, my boost lib version is 1.57, I use Winforms in my program.
But when I include “chaiscript/chaiscript.hpp” in stdafx.h, I got error with " can’t find _InterlockedExchang "

Please see the output:

------ 已启动生成: 项目: HelloWorld, 配置: Debug Win32 ------
生成启动时间为 2014-11-6 19:39:44。
正在对“Debug\HelloWorld.unsuccessfulbuild”执行 Touch 任务。
C:\boost_1_57\include\boost-1_57\boost/smart_ptr/detail/spinlock_w32.hpp(62): error C3861: “_InterlockedExchange”: 找不到标识符
C:\boost_1_57\include\boost-1_57\boost/thread/win32/thread_primitives.hpp(241): error C3641: “boost::detail::win32::GetTickCount64emulation”: 用 /clr:pure 或 /clr:safe 编译的函数的调用约定“__stdcall ”无效
C:\boost_1_57\include\boost-1_57\boost/thread/win32/thread_primitives.hpp(311): error C2440: “=”: 无法从“boost::detail::win32::ticks_type (__stdcall *)(void)”转换为“boost::detail::win32::detail::gettickcount64_t”
使用 /clr:pure 和 /clr:safe 时,函数地址服从 __clrcall 调用约定;请考虑在目标类型中使用 __clrcall
C:\boost_1_57\include\boost-1_57\boost/thread/win32/basic_timed_mutex.hpp(52): error C3861: “_InterlockedExchange”: 找不到标识符
C:\boost_1_57\include\boost-1_57\boost/thread/win32/basic_timed_mutex.hpp(230): error C3861: “_InterlockedExchangeAdd”: 找不到标识符
C:\boost_1_57\include\boost-1_57\boost/thread/win32/once.hpp(202): error C3861: “_InterlockedExchange”: 找不到标识符
C:\boost_1_57\include\boost-1_57\boost/thread/win32/once.hpp(215): error C3861: “_InterlockedExchange”: 找不到标识符


已用时间 00:00:04.97
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========

Sorry, there is Chinese in the output, but you still will see the error, please help me

Best regard



I try to not use Winforms, compile the following code:

#include "stdafx.h"

#include <chaiscript/chaiscript.hpp>

std::string helloWorld(const std::string &t_name)
return "Hello " + t_name + “!”;

int main()
chaiscript::ChaiScript chai;


But I got error:

------ 已启动生成: 项目: test, 配置: Debug Win32 ------
生成启动时间为 2014-11-6 20:41:44。
正在对“Debug\test.unsuccessfulbuild”执行 Touch 任务。
LINK : fatal error LNK1104: 无法打开文件“libboost_thread-vc100-mt-gd-1_57.lib”


已用时间 00:00:01.17
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========

That means can’t link libboost_thread-vc100-mt-gd-1_57.lib, I have searched the directories of boost, no this lib…

I don’t know where is wrong, please help me…

Best regards



First, yes, 4.xx requires boost. It is no longer supported. You are free to use it, but if you are able to use MSVC 2013 or newer (2014 is currently in beta testing) it is STRONGLY recommended that you use ChaiScript 5+.

I see that you are using VS2010, so your only choice is to use ChaiScript 4.x, unfortunately.

It looks like you are trying to do a 32bit build with vc10.0, multithreaded, debug.

I recommend you use the build from boost that’s specifically for that version.

(all VisualStudio builds are available from here:

I believe the last version of boost that ChaiScript was tested with was version 1.55. I would expect 1.57 to work, but I have not tested it.

If you install the pre-built version of boost, the .lib files should link automatically.


Thank you very much for your replay.

I will try MSVC 2013 or 2014 later, and I will try boost 1.55.

Did you try to use C++ Builder XE7/XE6/XE5? I have worked on C++ Builder so many years, and I really enjoy the RAD with C++ Builder.

I knew I can use ChaiScripte 4.xx with boost lib on C++ Builder, but I’d like to use new version of ChaiScript in the future.

So could you please try ChaiScript 5.xx on C++ Builder? I have tried 5.4 on C++ Builder, compile error with “can’t find thread file”. Is the thread file only exist in MSVC 2013 or newer?

Best regards.



<thread> is part of the C++11 standard, it should work with any compiler that supports C++11.

So, if you use MSVC2013, I strongly suggest you also use ChaiScript 5.x.

I just tried C++ Builder: Builder only supports C++11 in “64bit Windows” mode. So if you add a “64bit Windows” target to you C++Builder project, you should be able to get it to compile. I tried it and it seems to work.



Which C++ Builder version you have tried? XE7?

So you mean I can not compile normal 32 bit program use ChaiScript 5.x on C++ Builder by now?


Correct, XE7, only 64bit is supported for ChaiScript 5.x. It’s a problem with XE7, not with ChaiScript. The 32bit XE7 is missing C++11 features.