diff --git a/docs/source/errors.rst b/docs/source/errors.rst index 5088c09e..a8a130c1 100644 --- a/docs/source/errors.rst +++ b/docs/source/errors.rst @@ -5,6 +5,15 @@ how to handle exceptions or other errors Here is some advice and some tricks to use when dealing with thrown exceptions, error conditions and the like in Sol. + +Linker Errors +------------- + +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. + +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. + + Catch and CRASH! ---------------- diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index 1153b212..a2f8d5ed 100644 --- a/single/sol/sol.hpp +++ b/single/sol/sol.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2016-12-26 19:02:10.449461 UTC -// This header was generated with sol v2.15.5 (revision a2691c6) +// Generated 2017-01-02 14:35:36.677712 UTC +// This header was generated with sol v2.15.5 (revision bacd93a) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -790,7 +790,13 @@ namespace sol { // beginning of sol/compatibility/version.hpp +#ifdef SOL_USING_CXX_LUA +#include +#include +#include +#else #include +#endif // C++-compiler Lua #if defined(_WIN32) || defined(_MSC_VER) #ifndef SOL_CODECVT_SUPPORT diff --git a/sol/compatibility/version.hpp b/sol/compatibility/version.hpp index cf23c712..8f4882d5 100644 --- a/sol/compatibility/version.hpp +++ b/sol/compatibility/version.hpp @@ -22,7 +22,13 @@ #ifndef SOL_VERSION_HPP #define SOL_VERSION_HPP +#ifdef SOL_USING_CXX_LUA +#include +#include +#include +#else #include +#endif // C++-compiler Lua #if defined(_WIN32) || defined(_MSC_VER) #ifndef SOL_CODECVT_SUPPORT