Linking errors when lua compiled as C++

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Linking errors when lua compiled as C++

Roman Senuta
Hello,

  I have a problem with linking my application with luabind and lua
libraries when lua library is compiled as C++ code. Linker gives a lot
of undefined reference errors to lua functions:

luabind_lib/libluabind.a(exception_handler.cpp.o): In function
`luabind::detail::(anonymous
namespace)::push_exception_string(lua_State*, char const*, char const*)':
exception_handler.cpp:(.text+0x23): undefined reference to `lua_pushstring'
exception_handler.cpp:(.text+0x36): undefined reference to `lua_pushstring'
exception_handler.cpp:(.text+0x49): undefined reference to `lua_pushstring'
...

Problem is in lua_include.hpp header. It includes lua headers inside
extern "C" declaration. I had to hack it to make linking right. Is there
any way to do it better without altering luabind's source code?

--
Roman

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Linking errors when lua compiled as C++

Daniel Wallin
On Fri, Feb 26, 2010 at 01:00:31PM +0300, Roman Senuta wrote:
> Hello,

Hi,

>   I have a problem with linking my application with luabind and lua
> libraries when lua library is compiled as C++ code. Linker gives a lot
> of undefined reference errors to lua functions:
>
> luabind_lib/libluabind.a(exception_handler.cpp.o): In function
> `luabind::detail::(anonymous
> namespace)::push_exception_string(lua_State*, char const*, char const*)':
> exception_handler.cpp:(.text+0x23): undefined reference to `lua_pushstring'
> exception_handler.cpp:(.text+0x36): undefined reference to `lua_pushstring'
> exception_handler.cpp:(.text+0x49): undefined reference to `lua_pushstring'
> ...
>
> Problem is in lua_include.hpp header. It includes lua headers inside
> extern "C" declaration. I had to hack it to make linking right. Is there
> any way to do it better without altering luabind's source code?

No not right now. I suppose we could have a define for it,
LUABIND_CPLUSPLUS_LUA or something, and wrap the extern "C" lines in an
ifdef. Want do contribute a patch?

--
Daniel Wallin
BoostPro Computing
http://www.boostpro.com

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Linking errors when lua compiled as C++

Roman Senuta
In reply to this post by Roman Senuta
 > No not right now. I suppose we could have a define for it,
LUABIND_CPLUSPLUS_LUA or something, and wrap the extern "C" lines in an
 > ifdef. Want do contribute a patch?

Yep, that's exactly what I've done. Here is the patch:

--- luabind/lua_include.hpp     2010-01-04 02:08:15.000000000 +0300
+++ luabind/lua_include.hpp     2010-02-26 14:50:23.000000000 +0300
@@ -23,11 +23,17 @@
 #ifndef LUA_INCLUDE_HPP_INCLUDED
 #define LUA_INCLUDE_HPP_INCLUDED
 
+#ifndef LUABIND_CPLUSPLUS_LUA
 extern "C"
 {
+#endif
+
        #include "lua.h"
        #include "lauxlib.h"
+
+#ifndef LUABIND_CPLUSPLUS_LUA
 }
+#endif
 
 #endif

--
Roman


--- luabind/lua_include.hpp 2010-01-04 02:08:15.000000000 +0300
+++ luabind/lua_include.hpp 2010-02-26 14:50:23.000000000 +0300
@@ -23,11 +23,17 @@
 #ifndef LUA_INCLUDE_HPP_INCLUDED
 #define LUA_INCLUDE_HPP_INCLUDED
 
+#ifndef LUABIND_CPLUSPLUS_LUA
 extern "C"
 {
+#endif
+
  #include "lua.h"
  #include "lauxlib.h"
+
+#ifndef LUABIND_CPLUSPLUS_LUA
 }
+#endif
 
 #endif
 

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Linking errors when lua compiled as C++

Daniel Wallin
On Fri, Feb 26, 2010 at 02:58:56PM +0300, Roman Senuta wrote:
> > No not right now. I suppose we could have a define for it,
> LUABIND_CPLUSPLUS_LUA or something, and wrap the extern "C" lines in
> an
> > ifdef. Want do contribute a patch?
>
> Yep, that's exactly what I've done. Here is the patch:

Excellent, thank you. Applied in:

  http://github.com/luabind/luabind/commit/8ec02ed

--
Daniel Wallin
BoostPro Computing
http://www.boostpro.com

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user