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
306 stars 59 forks source link

Build fails on Windows #103

Closed MagicD3VIL closed 2 years ago

MagicD3VIL commented 3 years ago

Greetings, I am building on Windows 7 64bit using Visual Studio 2015 but the build seems to fail while building the executables (libraries seem ok). I am using the same CMake configuration I used on Linux (except the path changes of course) where it was built without any issues. Lua is version 5.3.6, wxWidgets 3.0.5. and I have built everything (Lua and wxWidgets) as Release x64.

Build log

1>------ Rebuild All started: Project: ZERO_CHECK, Configuration: Release x64 ------
1>  Checking Build System
2>------ Rebuild All started: Project: wxLuaLib, Configuration: Release x64 ------
3>------ Rebuild All started: Project: wxLuaModule, Configuration: Release x64 ------
2>  Building Custom Rule C:/Users/MagicD3VIL/Documents/wxLua/wxLua/modules/wxlua/CMakeLists.txt
2>  bit.c
2>  lbitlib.c
2>  dummy.cpp
2>  wxlbind.cpp
2>  wxlcallb.cpp
2>  wxlconsole.cpp
2>  wxllua.cpp
2>  wxlobject.cpp
3>  Building Custom Rule C:/Users/MagicD3VIL/Documents/wxLua/wxLua/modules/luamodule/CMakeLists.txt
2>  wxlstate.cpp
2>  wxlua_bind.cpp
3>  luamodule.cpp
3>  wxgl_bind.cpp
3>  wxstc_bind.cpp
3>  wxxrc_bind.cpp
3>  wxrichtext_bind.cpp
3>  wxhtml_bind.cpp
3>  wxhtml_wxlhtml.cpp
3>C:\Users\MagicD3VIL\Documents\wxLua\wxLua\modules\wxbind\src\wxstc_bind.cpp(14081): warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning)
3>  wxmedia_bind.cpp
3>  wxaui_bind.cpp
2>     Creating library C:/Users/MagicD3VIL/Documents/wxLua/wxLua/windows-build/lib/Release/wxlua-wx30mswu-3.1.0.0.lib and object C:/Users/MagicD3VIL/Documents/wxLua/wxLua/windows-build/lib/Release/wxlua-wx30mswu-3.1.0.0.exp
3>  wxadv_bind.cpp
2>  wxLuaLib.vcxproj -> C:\Users\MagicD3VIL\Documents\wxLua\wxLua\windows-build\bin\Release\wxlua-wx30mswu-3.1.0.0.dll
3>  wxadv_wxladv.cpp
3>  wxcore_appframe.cpp
4>------ Rebuild All started: Project: wxLuaBindLib, Configuration: Release x64 ------
5>------ Rebuild All started: Project: wxLuaDebugLib, Configuration: Release x64 ------
3>  wxcore_bind.cpp
3>  wxcore_clipdrag.cpp
3>  wxcore_controls.cpp
3>  wxcore_core.cpp
3>  wxcore_defsutils.cpp
3>  wxcore_dialogs.cpp
5>  Building Custom Rule C:/Users/MagicD3VIL/Documents/wxLua/wxLua/modules/wxlua/debug/CMakeLists.txt
5>  dummy.cpp
5>  wxldebug.cpp
5>  wxlstack.cpp
4>  Building Custom Rule C:/Users/MagicD3VIL/Documents/wxLua/wxLua/modules/wxbind/CMakeLists.txt
3>  wxcore_event.cpp
4>  wxgl_bind.cpp
4>  wxstc_bind.cpp
4>  wxxrc_bind.cpp
4>  wxrichtext_bind.cpp
4>  wxhtml_bind.cpp
4>  wxhtml_wxlhtml.cpp
3>  wxcore_gdi.cpp
3>  wxcore_geometry.cpp
3>  wxcore_graphics.cpp
3>  wxcore_help.cpp
3>  wxcore_image.cpp
4>  wxmedia_bind.cpp
3>  wxcore_mdi.cpp
4>  wxaui_bind.cpp
4>C:\Users\MagicD3VIL\Documents\wxLua\wxLua\modules\wxbind\src\wxstc_bind.cpp(14081): warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning)
4>  wxadv_bind.cpp
3>  wxcore_menutool.cpp
4>  wxadv_wxladv.cpp
3>  wxcore_picker.cpp
3>  wxcore_print.cpp
3>  wxcore_sizer.cpp
4>  wxcore_appframe.cpp
3>  wxcore_windows.cpp
4>  wxcore_bind.cpp
3>  wxcore_wxlcore.cpp
4>  wxcore_clipdrag.cpp
4>  wxcore_controls.cpp
3>  wxxml_bind.cpp
3>  wxnet_bind.cpp
4>  wxcore_core.cpp
3>  wxbase_base.cpp
5>     Creating library C:/Users/MagicD3VIL/Documents/wxLua/wxLua/windows-build/lib/Release/wxlua_debug-wx30mswu-3.1.0.0.lib and object C:/Users/MagicD3VIL/Documents/wxLua/wxLua/windows-build/lib/Release/wxlua_debug-wx30mswu-3.1.0.0.exp
3>  wxbase_bind.cpp
4>  wxcore_defsutils.cpp
3>  wxbase_config.cpp
3>  wxbase_data.cpp
4>  wxcore_dialogs.cpp
4>  wxcore_event.cpp
5>  wxLuaDebugLib.vcxproj -> C:\Users\MagicD3VIL\Documents\wxLua\wxLua\windows-build\bin\Release\wxlua_debug-wx30mswu-3.1.0.0.dll
3>  wxbase_datetime.cpp
3>  wxbase_file.cpp
4>  wxcore_gdi.cpp
3>  wxldserv.cpp
4>  wxcore_geometry.cpp
3>  wxldtarg.cpp
3>  wxlsock.cpp
3>  wxluadebugger_bind.cpp
4>  wxcore_graphics.cpp
4>  wxcore_help.cpp
4>  wxcore_image.cpp
3>  wxldebug.cpp
3>  wxlstack.cpp
3>  wxlbind.cpp
4>  wxcore_mdi.cpp
3>  wxlcallb.cpp
3>  wxlconsole.cpp
4>  wxcore_menutool.cpp
4>  wxcore_picker.cpp
3>  wxllua.cpp
3>  wxlobject.cpp
4>  wxcore_print.cpp
3>  wxlstate.cpp
3>  wxlua_bind.cpp
4>  wxcore_sizer.cpp
4>  wxcore_windows.cpp
4>  wxcore_wxlcore.cpp
4>  wxxml_bind.cpp
4>  wxnet_bind.cpp
4>  wxbase_base.cpp
4>  wxbase_bind.cpp
4>  wxbase_config.cpp
4>  wxbase_data.cpp
4>  wxbase_datetime.cpp
4>  wxbase_file.cpp
3>  dummy.cpp
4>     Creating library C:/Users/MagicD3VIL/Documents/wxLua/wxLua/windows-build/lib/Release/wxlua_bind-wx30mswu-3.1.0.0.lib and object C:/Users/MagicD3VIL/Documents/wxLua/wxLua/windows-build/lib/Release/wxlua_bind-wx30mswu-3.1.0.0.exp
4>  wxLuaBindLib.vcxproj -> C:\Users\MagicD3VIL\Documents\wxLua\wxLua\windows-build\bin\Release\wxlua_bind-wx30mswu-3.1.0.0.dll
6>------ Rebuild All started: Project: wxLuaDebuggerLib, Configuration: Release x64 ------
3>  dummy.cpp
6>  Building Custom Rule C:/Users/MagicD3VIL/Documents/wxLua/wxLua/modules/wxlua/debugger/CMakeLists.txt
6>  dummy.cpp
6>  wxldserv.cpp
6>  wxldtarg.cpp
6>  wxlsock.cpp
6>  wxluadebugger_bind.cpp
3>  bit.c
3>  lbitlib.c
3>  dummy.cpp
6>     Creating library C:/Users/MagicD3VIL/Documents/wxLua/wxLua/windows-build/lib/Release/wxlua_debugger-wx30mswu-3.1.0.0.lib and object C:/Users/MagicD3VIL/Documents/wxLua/wxLua/windows-build/lib/Release/wxlua_debugger-wx30mswu-3.1.0.0.exp
6>  wxLuaDebuggerLib.vcxproj -> C:\Users\MagicD3VIL\Documents\wxLua\wxLua\windows-build\bin\Release\wxlua_debugger-wx30mswu-3.1.0.0.dll
7>------ Rebuild All started: Project: wxLuaCan, Configuration: Release x64 ------
8>------ Rebuild All started: Project: wxLuaFreeze, Configuration: Release x64 ------
9>------ Rebuild All started: Project: wxLua_app, Configuration: Release x64 ------
7>  Building Custom Rule C:/Users/MagicD3VIL/Documents/wxLua/wxLua/apps/wxluacan/CMakeLists.txt
8>  Building Custom Rule C:/Users/MagicD3VIL/Documents/wxLua/wxLua/apps/wxluafreeze/CMakeLists.txt
8>  wxluafreeze.cpp
7>  cancom.cpp
7>  canlua.cpp
7>  cansim.cpp
7>  wxluacan_bind.cpp
9>  Building Custom Rule C:/Users/MagicD3VIL/Documents/wxLua/wxLua/apps/wxlua/CMakeLists.txt
9>  wxlua.cpp
3>     Creating library C:/Users/MagicD3VIL/Documents/wxLua/wxLua/windows-build/lib/Release/wx.lib and object C:/Users/MagicD3VIL/Documents/wxLua/wxLua/windows-build/lib/Release/wx.exp
3>  wxLuaModule.vcxproj -> C:\Users\MagicD3VIL\Documents\wxLua\wxLua\windows-build\bin\Release\wx.dll
8>wxluafreeze.obj : error LNK2019: unresolved external symbol "class wxEventTypeTag<class wxLuaEvent> const wxEVT_LUA_PRINT" (?wxEVT_LUA_PRINT@@3V?$wxEventTypeTag@VwxLuaEvent@@@@B) referenced in function "void __cdecl `dynamic initializer for 'private: static struct wxEventTableEntry const * const wxLuaFreezeApp::sm_eventTableEntries''(void)" (??__E?sm_eventTableEntries@wxLuaFreezeApp@@0QBUwxEventTableEntry@@B@@YAXXZ)
8>wxluafreeze.obj : error LNK2019: unresolved external symbol "class wxEventTypeTag<class wxLuaEvent> const wxEVT_LUA_ERROR" (?wxEVT_LUA_ERROR@@3V?$wxEventTypeTag@VwxLuaEvent@@@@B) referenced in function "void __cdecl `dynamic initializer for 'private: static struct wxEventTableEntry const * const wxLuaFreezeApp::sm_eventTableEntries''(void)" (??__E?sm_eventTableEntries@wxLuaFreezeApp@@0QBUwxEventTableEntry@@B@@YAXXZ)
8>C:\Users\MagicD3VIL\Documents\wxLua\wxLua\windows-build\bin\Release\wxLuaFreeze.exe : fatal error LNK1120: 2 unresolved externals
7>canlua.obj : error LNK2019: unresolved external symbol "class wxEventTypeTag<class wxLuaEvent> const wxEVT_LUA_ERROR" (?wxEVT_LUA_ERROR@@3V?$wxEventTypeTag@VwxLuaEvent@@@@B) referenced in function "public: virtual void __cdecl wxlCanObjScript::DoDraw(class wxDC &,double,double)" (?DoDraw@wxlCanObjScript@@UEAAXAEAVwxDC@@NN@Z)
7>cansim.obj : error LNK2001: unresolved external symbol "class wxEventTypeTag<class wxLuaEvent> const wxEVT_LUA_ERROR" (?wxEVT_LUA_ERROR@@3V?$wxEventTypeTag@VwxLuaEvent@@@@B)
7>cansim.obj : error LNK2019: unresolved external symbol "class wxEventTypeTag<class wxLuaEvent> const wxEVT_LUA_PRINT" (?wxEVT_LUA_PRINT@@3V?$wxEventTypeTag@VwxLuaEvent@@@@B) referenced in function "void __cdecl `dynamic initializer for 'private: static struct wxEventTableEntry const * const MyFrame::sm_eventTableEntries''(void)" (??__E?sm_eventTableEntries@MyFrame@@0QBUwxEventTableEntry@@B@@YAXXZ)
7>cansim.obj : error LNK2019: unresolved external symbol "class wxEventTypeTag<class wxLuaEvent> const wxEVT_LUA_DEBUG_HOOK" (?wxEVT_LUA_DEBUG_HOOK@@3V?$wxEventTypeTag@VwxLuaEvent@@@@B) referenced in function "void __cdecl `dynamic initializer for 'private: static struct wxEventTableEntry const * const MyFrame::sm_eventTableEntries''(void)" (??__E?sm_eventTableEntries@MyFrame@@0QBUwxEventTableEntry@@B@@YAXXZ)
7>C:\Users\MagicD3VIL\Documents\wxLua\wxLua\windows-build\bin\Release\wxLuaCan.exe : fatal error LNK1120: 3 unresolved externals
9>wxlua.obj : error LNK2019: unresolved external symbol "class wxEventTypeTag<class wxLuaEvent> const wxEVT_LUA_PRINT" (?wxEVT_LUA_PRINT@@3V?$wxEventTypeTag@VwxLuaEvent@@@@B) referenced in function "void __cdecl `dynamic initializer for 'private: static struct wxEventTableEntry const * const wxLuaStandaloneApp::sm_eventTableEntries''(void)" (??__E?sm_eventTableEntries@wxLuaStandaloneApp@@0QBUwxEventTableEntry@@B@@YAXXZ)
9>wxlua.obj : error LNK2019: unresolved external symbol "class wxEventTypeTag<class wxLuaEvent> const wxEVT_LUA_ERROR" (?wxEVT_LUA_ERROR@@3V?$wxEventTypeTag@VwxLuaEvent@@@@B) referenced in function "void __cdecl `dynamic initializer for 'private: static struct wxEventTableEntry const * const wxLuaStandaloneApp::sm_eventTableEntries''(void)" (??__E?sm_eventTableEntries@wxLuaStandaloneApp@@0QBUwxEventTableEntry@@B@@YAXXZ)
9>C:\Users\MagicD3VIL\Documents\wxLua\wxLua\windows-build\bin\Release\wxLua.exe : fatal error LNK1120: 2 unresolved externals
10>------ Rebuild All started: Project: ALL_BUILD, Configuration: Release x64 ------
10>  Building Custom Rule C:/Users/MagicD3VIL/Documents/wxLua/wxLua/CMakeLists.txt
========== Rebuild All: 7 succeeded, 3 failed, 0 skipped ==========

I don't build on Windows often so I really don't know how to fix these issues thus any help will be much appreciated. I can provide the solution file if it's needed.

Cheers

pkulchenko commented 3 years ago

The issue seems to apply only to wxluafreeze. Do you need to build this particular application? I think it's been this way for a while, but since I don't use that app and noone else expressed any interest in fixing it, it continues to fail. I've considered removing it completely, but if someone wants to fix it, I'd rather try to make it work instead of removing.

MagicD3VIL commented 3 years ago

I indeed don't need wxLuaFreeze. Can I (if so, how) remove it from the solution so that the wxLua.exe builds successfully? I'm pretty sure I only need wxLua.exe and wx.dll.

pkulchenko commented 3 years ago

Yes, wxLua.exe doesn't depend on wxLuaFreeze.

MagicD3VIL commented 3 years ago

It seems that the linker still has problems with unresolved externals. Microsoft's website lists a lot of reasons why this might be and since I've never encountered this, I have no idea how to resolve it. :confused:

EDIT: log

3>     Creating library C:/Users/MagicD3VIL/Documents/wxLua/wxLua/windows-build/lib/Release/wx.lib and object C:/Users/MagicD3VIL/Documents/wxLua/wxLua/windows-build/lib/Release/wx.exp
3>  wxLuaModule.vcxproj -> C:\Users\MagicD3VIL\Documents\wxLua\wxLua\windows-build\bin\Release\wx.dll
9>canlua.obj : error LNK2019: unresolved external symbol "class wxEventTypeTag<class wxLuaEvent> const wxEVT_LUA_ERROR" (?wxEVT_LUA_ERROR@@3V?$wxEventTypeTag@VwxLuaEvent@@@@B) referenced in function "public: virtual void __cdecl wxlCanObjScript::DoDraw(class wxDC &,double,double)" (?DoDraw@wxlCanObjScript@@UEAAXAEAVwxDC@@NN@Z)
10>wxlua.obj : error LNK2019: unresolved external symbol "class wxEventTypeTag<class wxLuaEvent> const wxEVT_LUA_PRINT" (?wxEVT_LUA_PRINT@@3V?$wxEventTypeTag@VwxLuaEvent@@@@B) referenced in function "void __cdecl `dynamic initializer for 'private: static struct wxEventTableEntry const * const wxLuaStandaloneApp::sm_eventTableEntries''(void)" (??__E?sm_eventTableEntries@wxLuaStandaloneApp@@0QBUwxEventTableEntry@@B@@YAXXZ)
10>wxlua.obj : error LNK2019: unresolved external symbol "class wxEventTypeTag<class wxLuaEvent> const wxEVT_LUA_ERROR" (?wxEVT_LUA_ERROR@@3V?$wxEventTypeTag@VwxLuaEvent@@@@B) referenced in function "void __cdecl `dynamic initializer for 'private: static struct wxEventTableEntry const * const wxLuaStandaloneApp::sm_eventTableEntries''(void)" (??__E?sm_eventTableEntries@wxLuaStandaloneApp@@0QBUwxEventTableEntry@@B@@YAXXZ)
9>cansim.obj : error LNK2001: unresolved external symbol "class wxEventTypeTag<class wxLuaEvent> const wxEVT_LUA_ERROR" (?wxEVT_LUA_ERROR@@3V?$wxEventTypeTag@VwxLuaEvent@@@@B)
9>cansim.obj : error LNK2019: unresolved external symbol "class wxEventTypeTag<class wxLuaEvent> const wxEVT_LUA_PRINT" (?wxEVT_LUA_PRINT@@3V?$wxEventTypeTag@VwxLuaEvent@@@@B) referenced in function "void __cdecl `dynamic initializer for 'private: static struct wxEventTableEntry const * const MyFrame::sm_eventTableEntries''(void)" (??__E?sm_eventTableEntries@MyFrame@@0QBUwxEventTableEntry@@B@@YAXXZ)
9>cansim.obj : error LNK2019: unresolved external symbol "class wxEventTypeTag<class wxLuaEvent> const wxEVT_LUA_DEBUG_HOOK" (?wxEVT_LUA_DEBUG_HOOK@@3V?$wxEventTypeTag@VwxLuaEvent@@@@B) referenced in function "void __cdecl `dynamic initializer for 'private: static struct wxEventTableEntry const * const MyFrame::sm_eventTableEntries''(void)" (??__E?sm_eventTableEntries@MyFrame@@0QBUwxEventTableEntry@@B@@YAXXZ)
9>C:\Users\MagicD3VIL\Documents\wxLua\wxLua\windows-build\bin\Release\wxLuaCan.exe : fatal error LNK1120: 3 unresolved externals
10>C:\Users\MagicD3VIL\Documents\wxLua\wxLua\windows-build\bin\Release\wxLua.exe : fatal error LNK1120: 2 unresolved externals
11>------ Rebuild All started: Project: ALL_BUILD, Configuration: Release x64 ------
11>  Building Custom Rule C:/Users/MagicD3VIL/Documents/wxLua/wxLua/CMakeLists.txt
12>------ Skipped Rebuild All: Project: PACKAGE, Configuration: Release x64 ------
12>Project not selected to build for this solution configuration 
========== Rebuild All: 7 succeeded, 2 failed, 3 skipped ==========
pkulchenko commented 3 years ago

wxlua application (wxLua/apps/wxlua/wxlua.cpp) actually includes the following code, so I'm not sure why those constants are not defined:

BEGIN_EVENT_TABLE(wxLuaStandaloneApp, wxApp)
    EVT_LUA_PRINT       (wxID_ANY, wxLuaStandaloneApp::OnLua)
    EVT_LUA_ERROR       (wxID_ANY, wxLuaStandaloneApp::OnLua)
    //EVT_LUA_DEBUG_HOOK  (wxID_ANY, wxLuaStandaloneApp::OnLua)
END_EVENT_TABLE()

If you want to use wxlua, you don't need to necessarily use wxlua, as you can load wx.dll from any lua interpreter (that is compiled against the same version of Lua). You just need to make wx.dll available to your script and to require 'wx' in it.

MagicD3VIL commented 3 years ago

Yep, I know I need just libwx.so for Linux and wx.dll for Windows to run wxLua. I just didn't understand why building the executables on Windows didn't work. I guess this is just some linker environment issue and has really nothing to do with wxLua itself so feel free to close this issue.

Interesting how building on Linux is hassle-free when some would expect it to be the other way around. Also, I just want to say that I appreciate the swiftness of Your responses.

Cheers

pkulchenko commented 2 years ago

I'm still not sure why exactly these errors are generated, but I don't have the Microsoft build environment to troubleshoot and figure it out. If anyone has more information on this or some ideas on how to fix, please update the ticket.