Skip to content

Commit 010b6bb

Browse files
committed
allow for switch to change Lua configuration and build with assumptions to C++ handling
1 parent bacd93a commit 010b6bb

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

docs/source/errors.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ how to handle exceptions or other errors
55

66
Here is some advice and some tricks to use when dealing with thrown exceptions, error conditions and the like in Sol.
77

8+
9+
Linker Errors
10+
-------------
11+
12+
There are lots of reasons for compiler linker errors. A common one is not knowing that you've compiled the Lua library as C++: when building with C++, it is important to note that every typical (static or dynamic) library expects the C calling convention to be used and that Sol includes the code using ``extern 'C'`` where applicable.
13+
14+
However, when the target Lua library is compiled with C++, one must change the calling convention and name mangling scheme by getting rid of the ``extern 'C'`` block. This can be achieved by adding ``#define SOL_USING_CXX_LUA`` before including sol2, or by adding it to your compilation's command line.
15+
16+
817
Catch and CRASH!
918
----------------
1019

single/sol/sol.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
// This file was generated with a script.
23-
// Generated 2016-12-26 19:02:10.449461 UTC
24-
// This header was generated with sol v2.15.5 (revision a2691c6)
23+
// Generated 2017-01-02 14:35:36.677712 UTC
24+
// This header was generated with sol v2.15.5 (revision bacd93a)
2525
// https://github.com/ThePhD/sol2
2626

2727
#ifndef SOL_SINGLE_INCLUDE_HPP
@@ -790,7 +790,13 @@ namespace sol {
790790

791791
// beginning of sol/compatibility/version.hpp
792792

793+
#ifdef SOL_USING_CXX_LUA
794+
#include <lua.h>
795+
#include <lualib.h>
796+
#include <luaxlib.h>
797+
#else
793798
#include <lua.hpp>
799+
#endif // C++-compiler Lua
794800

795801
#if defined(_WIN32) || defined(_MSC_VER)
796802
#ifndef SOL_CODECVT_SUPPORT

sol/compatibility/version.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@
2222
#ifndef SOL_VERSION_HPP
2323
#define SOL_VERSION_HPP
2424

25+
#ifdef SOL_USING_CXX_LUA
26+
#include <lua.h>
27+
#include <lualib.h>
28+
#include <luaxlib.h>
29+
#else
2530
#include <lua.hpp>
31+
#endif // C++-compiler Lua
2632

2733
#if defined(_WIN32) || defined(_MSC_VER)
2834
#ifndef SOL_CODECVT_SUPPORT

0 commit comments

Comments
 (0)