Closed ildar closed 4 years ago
@ildar, something is wrong, as wxMemoryBuffer
presence only depends on wxLUA_USE_wxMemoryBuffer
, which is set to 1 in modules/wxbind/setup/wxluasetup.h
. Is it not set to 1 in your case?
You can change the default value, but I don't see that you do in your build settings, so not sure why it wouldn't be included.
I maybe found something:
So I suspect libwxlua-wxd-3.0.0.8.so requiring wxluatype_wxMemoryBuffer is wrong.
Paul?
@ildar, what is this -wxd- library? I can't find references to it in the build scripts, so not sure why it's pulling in wxMemoryBuffer
. The only reference that is not protected by wxLUA_USE_wxMemoryBuffer
is in modules/wxlua/wxllua.cpp
, so maybe else if
where it's used does need to be wrapped into wxLUA_USE_wxMemoryBuffer
check, but I don't think this is causing the issue you see.
@toshinagata, based on your work on wxMemoryBuffer in #49, do you see something that could have caused the issue in this ticket? I don't see anything and it didn't come up in my builds, because I'm always building a monolithic library.
$ ls -lR wxlua-buildroot [...] wxlua-buildroot/usr/lib64: -rw-r--r-- 1 ildar ildar 6540272 апр 21 12:03 libwxlua_bind-wxd-3.0.0.8.so -rw-r--r-- 1 ildar ildar 322144 апр 21 12:04 libwxlua_debugger-wxd-3.0.0.8.so -rw-r--r-- 1 ildar ildar 457496 апр 21 12:02 libwxlua_debug-wxd-3.0.0.8.so -rw-r--r-- 1 ildar ildar 546040 апр 21 12:01 libwxlua-wxd-3.0.0.8.so drwxr-xr-x 3 ildar ildar 60 апр 21 12:04 lua [...] wxlua-buildroot-/usr/lib64/lua/5.1: -rw-r--r-- 1 ildar ildar 7239592 апр 21 12:03 wx.so [...]
@ildar, I believe you, I just can't figure out what these -wxd- libraries are. Can you show the complete list of libraries that is getting built?
Does it work when you add -DBUILD_SHARED_LIBS=FALSE
to cmake command? You should only get libwx.so
without wxlua dependencies in this case.
-DBUILD_SHARED_LIBS=FALSE
converted 3 libs into static that helped to
find out following:So: a. wx.so Lua module is away from this problem b. the libs with problematic linking only required for demo apps c. static linking of the apps solves the issues as expected. Though this kind of approach is strongly not recommended in ALTLinux.
ok, thank you for the detailed explanation. Given the result, I'm closing this ticket, but if you know what to fix to make it work for wxLua/wxLuaCan/wxLuaFreeze, please let me know and I'll apply the change.
@pkulchenko, I suspect we may need to modify wxllua.cpp so that every line including wxluatype_wxMemoryBuffer is wrapped inside "#if wxLUA_USE_wxMemoryBuffer ... #endif". I will give it a try when I have time.
@ildar, can you check the following patch to see if it fixes the compilation issue:
diff --git a/wxLua/modules/wxlua/wxllua.cpp b/wxLua/modules/wxlua/wxllua.cpp
index c01f74c..f5dfeb4 100644
--- a/wxLua/modules/wxlua/wxllua.cpp
+++ b/wxLua/modules/wxlua/wxllua.cpp
@@ -19,6 +19,7 @@
#include <wx/wx.h>
#endif
+#include "wxbind/setup/wxluasetup.h"
#include "wxlua/wxllua.h"
#include "wxlua/wxlstate.h"
#include "wxlua/wxlbind.h"
@@ -982,15 +983,20 @@ const wxLuaBindClass* LUACALL wxluaT_getclass(lua_State* L, const char* class_na
bool wxluaT_isuserdatatype(lua_State* L, int stack_idx, int wxl_type)
{
+#if wxLUA_USE_wxMemoryBuffer
extern int wxluatype_wxMemoryBuffer;
+#endif // wxLUA_USE_wxMemoryBuffer
int stack_type = wxluaT_type(L, stack_idx);
if (wxlua_iswxuserdatatype(stack_type) &&
((wxluatype_NULL == stack_type) || // FIXME, how to check when NULL is valid or not?
((wxl_type == WXLUA_TSTRING) &&
- ((wxluaT_isderivedtype(L, stack_type, *p_wxluatype_wxString) >= 0) ||
- (wxluaT_isderivedtype(L, stack_type, wxluatype_wxMemoryBuffer) >= 0))) ||
+ ((wxluaT_isderivedtype(L, stack_type, *p_wxluatype_wxString) >= 0)
+#if wxLUA_USE_wxMemoryBuffer
+ || (wxluaT_isderivedtype(L, stack_type, wxluatype_wxMemoryBuffer) >= 0)
+#endif // wxLUA_USE_wxMemoryBuffer
+ )) ||
(wxluaT_isderivedtype(L, stack_type, wxl_type) >= 0)))
return true;
@@ -1407,7 +1413,9 @@ const char* LUACALL wxlua_getstringtypelen(lua_State *L, int stack_idx, size_t *
return lua_tolstring(L, stack_idx, len);
else if (wxlua_iswxuserdata(L, stack_idx))
{
+#if wxLUA_USE_wxMemoryBuffer
extern int wxluatype_wxMemoryBuffer;
+#endif // wxLUA_USE_wxMemoryBuffer
int stack_type = wxluaT_type(L, stack_idx);
if (wxluaT_isderivedtype(L, stack_type, *p_wxluatype_wxString) >= 0)
@@ -1419,6 +1427,7 @@ const char* LUACALL wxlua_getstringtypelen(lua_State *L, int stack_idx, size_t *
*len = strlen(retp);
return retp;
}
+#if wxLUA_USE_wxMemoryBuffer
else if (wxluaT_isderivedtype(L, stack_type, wxluatype_wxMemoryBuffer) >= 0)
{
wxMemoryBuffer * wxmem = (wxMemoryBuffer *)wxluaT_getuserdatatype(L, stack_idx, wxluatype_wxMemoryBuffer);
@@ -1427,6 +1436,7 @@ const char* LUACALL wxlua_getstringtypelen(lua_State *L, int stack_idx, size_t *
*len = wxmem->GetDataLen();
return datap;
}
+#endif // wxLUA_USE_wxMemoryBuffer
}
wxlua_argerror(L, stack_idx, wxT("a 'string' or 'wxString'"));
@toshinagata, the patch above worked for me, but I don't like the fact that I needed to add #include "wxbind/setup/wxluasetup.h"
to get wxLUA_USE_wxMemoryBuffer
values. Do you have any better idea?
Just tried, it didn't help, sorry. I think if you need to use that variable in libwxlua, you'd better move it into the lib. Otherwise you have to use circular linking which is annoying etc. I may be wrong though as never dealt with such issues in practice.
@pkulchenko, @ildar, Maybe we need to avoid using 'extern int wxluatype_wxMemoryBuffer', but use a pointer to that global variable. This is what we do in p_wxluatype_wxString, although until now I was just wondering why we were using such an indirect way.
I'm not happy about it either. Since it didn't help @ildar, I'll keep the code as is. I pushed the changes to a separate branch, so they don't get lost.
Building wxLua dynamically like this: http://git.altlinux.org/people/ildar/packages/wxlua.git?p=wxlua.git;a=blob;f=wxlua.spec;h=e785ed4b644072b14a42dbbe1cc8050ab8909291;hb=8564f502394c85dd24b5b289557f0c1bac5fa62e#l86 Everything builds fine but the resulting libraries are faulty:
(this is the result of the command
ldd -d ./libwxlua-wxd-3.0.0.8.so
)