pkulchenko / wxlua

wxlua: Lua bindings for wxWidgets cross-platform GUI toolkit; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and wxWidgets 3.x
304 stars 59 forks source link

wxlua_app target failed to build on Mac OS 11.1 using Xcode #90

Closed programmingkidx closed 3 years ago

programmingkidx commented 3 years ago

When I try to make the wxlua_app target I see this error:

wxLua/modules/wxbind/src/wxadv_bind.cpp:14180:50: error: no member named 'GenericGetHeader' in 'wxDataViewCtrl' wxHeaderCtrl returns = (wxHeaderCtrl)self->GenericGetHeader();

I found a definition for this method here: https://github.com/wxWidgets/wxWidgets/blob/master/src/generic/datavgen.cpp

wxHeaderCtrl* wxDataViewCtrl::GenericGetHeader() const { return m_headerArea; }

I was not able to find any documentation for this method. This is the closest I came: https://fossies.org/dox/wxWidgets-3.1.4/classwxDataViewCtrl.html#a032c55e7699a16628c9f0bc4fb626884

pkulchenko commented 3 years ago

@programmingkidx, what version of wxwidgets are you compiling with?

programmingkidx commented 3 years ago

'wx-config --version' outputs 3.1.2.

pkulchenko commented 3 years ago

This is a bit confusing, as 3.1.2 was released on 2018-12-9 and the commit that introduced GenericGetHeader was made on 2016-04-22, so should definitely be included in 3.1.2

pkulchenko commented 3 years ago

@programmingkidx, can you try the following patch to wxlua to see if it fixes the issue:

diff --git a/wxLua/bindings/wxwidgets/wxadv_dataview.i b/wxLua/bindings/wxwidgets/wxadv_dataview.i
index cb93b85..ca06193 100644
--- a/wxLua/bindings/wxwidgets/wxadv_dataview.i
+++ b/wxLua/bindings/wxwidgets/wxadv_dataview.i
@@ -680,11 +680,11 @@ class wxDataViewCtrl : public wxDataViewCtrlBase
     virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL );
     virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column);

-#if %msw || !defined(wxUSE_NATIVE_DATAVIEWCTRL)
+#if defined(wxHAS_GENERIC_DATAVIEWCTRL)
     // The returned pointer is null if the control has wxDV_NO_HEADER style.
     //
     // This method is only available in the generic versions.
-    wxHeaderCtrl* GenericGetHeader() const;
+    %wxchkver_3_1_1 wxHeaderCtrl* GenericGetHeader() const;
 #endif
 };

diff --git a/wxLua/modules/wxbind/src/wxadv_bind.cpp b/wxLua/modules/wxbind/src/wxadv_bind.cpp
index 7ae3717..6dd8be3 100644
--- a/wxLua/modules/wxbind/src/wxadv_bind.cpp
+++ b/wxLua/modules/wxbind/src/wxadv_bind.cpp
@@ -14167,11 +14167,11 @@ static int LUACALL wxLua_wxDataViewCtrl_EnsureVisible(lua_State *L)
 }

-#if ((defined(__WXMSW__) || !defined (wxUSE_NATIVE_DATAVIEWCTRL )) && (wxCHECK_VERSION(3,1,0) && wxUSE_DATAVIEWCTRL && wxLUA_USE_wxDataViewCtrl)) && ((wxLUA_USE_wxButton && wxUSE_BUTTON) && (wxUSE_HEADERCTRL))
+#if (((defined (wxHAS_GENERIC_DATAVIEWCTRL )) && (wxCHECK_VERSION(3,1,0) && wxUSE_DATAVIEWCTRL && wxLUA_USE_wxDataViewCtrl)) && (wxCHECK_VERSION(3,1,1))) && ((wxLUA_USE_wxButton && wxUSE_BUTTON) && (wxUSE_HEADERCTRL))
 static wxLuaArgType s_wxluatypeArray_wxLua_wxDataViewCtrl_GenericGetHeader[] = { &wxluatype_wxDataViewCtrl, NULL };
 static int LUACALL wxLua_wxDataViewCtrl_GenericGetHeader(lua_State *L);
 static wxLuaBindCFunc s_wxluafunc_wxLua_wxDataViewCtrl_GenericGetHeader[1] = {{ wxLua_wxDataViewCtrl_GenericGetHeader, WXLUAMETHOD_METHOD, 1, 1, s_wxluatypeArray_wxLua_wxDataViewCtrl_GenericGetHeader }};
-//     wxHeaderCtrl* GenericGetHeader() const;
+//     %wxchkver_3_1_1 wxHeaderCtrl* GenericGetHeader() const;
 static int LUACALL wxLua_wxDataViewCtrl_GenericGetHeader(lua_State *L)
 {
     // get this
@@ -14184,7 +14184,7 @@ static int LUACALL wxLua_wxDataViewCtrl_GenericGetHeader(lua_State *L)
     return 1;
 }

-#endif // ((defined(__WXMSW__) || !defined (wxUSE_NATIVE_DATAVIEWCTRL )) && (wxCHECK_VERSION(3,1,0) && wxUSE_DATAVIEWCTRL && wxLUA_USE_wxDataViewCtrl)) && ((wxLUA_USE_wxButton && wxUSE_BUTTON) && (wxUSE_HEADERCTRL))
+#endif // (((defined (wxHAS_GENERIC_DATAVIEWCTRL )) && (wxCHECK_VERSION(3,1,0) && wxUSE_DATAVIEWCTRL && wxLUA_USE_wxDataViewCtrl)) && (wxCHECK_VERSION(3,1,1))) && ((wxLUA_USE_wxButton && wxUSE_BUTTON) && (wxUSE_HEADERCTRL))

 static wxLuaArgType s_wxluatypeArray_wxLua_wxDataViewCtrl_GetColumn[] = { &wxluatype_wxDataViewCtrl, &wxluatype_TINTEGER, NULL };
 static int LUACALL wxLua_wxDataViewCtrl_GetColumn(lua_State *L);
@@ -14534,9 +14534,9 @@ wxLuaBindMethod wxDataViewCtrl_methods[] = {
     { "EditItem", WXLUAMETHOD_METHOD, s_wxluafunc_wxLua_wxDataViewCtrl_EditItem, 1, NULL },
     { "EnsureVisible", WXLUAMETHOD_METHOD, s_wxluafunc_wxLua_wxDataViewCtrl_EnsureVisible, 1, NULL },

-#if ((defined(__WXMSW__) || !defined (wxUSE_NATIVE_DATAVIEWCTRL )) && (wxCHECK_VERSION(3,1,0) && wxUSE_DATAVIEWCTRL && wxLUA_USE_wxDataViewCtrl)) && ((wxLUA_USE_wxButton && wxUSE_BUTTON) && (wxUSE_HEADERCTRL))
+#if (((defined (wxHAS_GENERIC_DATAVIEWCTRL )) && (wxCHECK_VERSION(3,1,0) && wxUSE_DATAVIEWCTRL && wxLUA_USE_wxDataViewCtrl)) && (wxCHECK_VERSION(3,1,1))) && ((wxLUA_USE_wxButton && wxUSE_BUTTON) && (wxUSE_HEADERCTRL))
     { "GenericGetHeader", WXLUAMETHOD_METHOD, s_wxluafunc_wxLua_wxDataViewCtrl_GenericGetHeader, 1, NULL },
-#endif // ((defined(__WXMSW__) || !defined (wxUSE_NATIVE_DATAVIEWCTRL )) && (wxCHECK_VERSION(3,1,0) && wxUSE_DATAVIEWCTRL && wxLUA_USE_wxDataViewCtrl)) && ((wxLUA_USE_wxButton && wxUSE_BUTTON) && (wxUSE_HEADERCTRL))
+#endif // (((defined (wxHAS_GENERIC_DATAVIEWCTRL )) && (wxCHECK_VERSION(3,1,0) && wxUSE_DATAVIEWCTRL && wxLUA_USE_wxDataViewCtrl)) && (wxCHECK_VERSION(3,1,1))) && ((wxLUA_USE_wxButton && wxUSE_BUTTON) && (wxUSE_HEADERCTRL))

     { "GetColumn", WXLUAMETHOD_METHOD, s_wxluafunc_wxLua_wxDataViewCtrl_GetColumn, 1, NULL },
     { "GetColumnCount", WXLUAMETHOD_METHOD, s_wxluafunc_wxLua_wxDataViewCtrl_GetColumnCount, 1, NULL },

You may need to run make clean from wxLua folder.

programmingkidx commented 3 years ago

I think this fixes the GenericGetHeader() problem. Now I see over 100 messages for undefined symbols.

Here are some of the messages: Undefined symbol: wxAboutBox(wxAboutDialogInfo const&, wxWindow) Undefined symbol: wxCopyFile(wxString const&, wxString const&, bool) Undefined symbol: wxOnAssert(char const, int, char const, char const, wchar_t const*)

It doesn't appear to be linking with wxWidgets for some reason. I do see all the libraries that 'wx-config --libs' returns in the target's link settings. Not sure what is going on.

programmingkidx commented 3 years ago

Doing more research this is what I found out. The ARM wxLua binary is trying to link with x86_64 libraries:

Showing All Messages Ignoring file /usr/local/lib/libwx_osx_cocoau_gl-3.1.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64

Ignoring file /usr/local/lib/libwx_osx_cocoau_xrc-3.1.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64

Ignoring file /usr/local/lib/libwx_baseu_net-3.1.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64

Ignoring file /usr/local/lib/libwx_osx_cocoau_media-3.1.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64

Ignoring file /usr/local/lib/libwx_osx_cocoau_richtext-3.1.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64

Ignoring file /usr/local/lib/libwx_osx_cocoau_aui-3.1.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64

Ignoring file /usr/local/lib/libwx_baseu_xml-3.1.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64

Ignoring file /usr/local/lib/libwx_osx_cocoau_stc-3.1.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64

Ignoring file /usr/local/lib/libwx_osx_cocoau_html-3.1.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64

Ignoring file /usr/local/lib/libwx_baseu-3.1.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64

Ignoring file /usr/local/lib/libwx_osx_cocoau_core-3.1.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64

pkulchenko commented 3 years ago

I pushed the fix for GenericGetHeader.

It doesn't appear to be linking with wxWidgets for some reason. I do see all the libraries that 'wx-config --libs' returns in the target's link settings. Not sure what is going on.

I'm not sure either. How does your cmake wxlua command look like? I suspect that compiler ID checks in cmake don't take arm64 into account. What do you see detected in CMakeCXXCompiler.cmake and/or CMakeCCompiler.cmake?

programmingkidx commented 3 years ago

When I run CMake I do see it finding wxwidgets. It does look like there needs to be architecture detection code added to prevent this situation from happening.

pkulchenko commented 3 years ago

@programmingkidx, try setting -DCMAKE_OSX_ARCHITECTURES=arm64 option for wxlua cmake.