Author Topic: Weird linking error on wxSmith plugin on Windows  (Read 8081 times)

Online stahta01

  • Lives here!
  • ****
  • Posts: 7589
    • My Best Post
Weird linking error on wxSmith plugin on Windows
« on: July 20, 2016, 02:58:05 am »
Likely caused by
Commit [r10872]
"* Linux (autofoo): use system provided squirrel if installed (based on Fedoras unbundle-patch)".

Patch that needs more testing below. Deleted patch that had an typo in it.


Edit: It took me 4 hours the find the cause; too tired to do any more testing.
Edit2: Now my fix is NOT working I give up; maybe my computer is being haunted.

Tim S.
« Last Edit: July 20, 2016, 07:12:14 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Weird linking error on wxSmith plugin on Windows
« Reply #1 on: July 20, 2016, 10:43:48 am »
Did you build C::B from clean sources (make sure all former build suirrel lib(s) are removed ?
If that does not work:
did you try to completely revert this change (just comment out the "#undef"") and build C::B from clean sources ?

Online stahta01

  • Lives here!
  • ****
  • Posts: 7589
    • My Best Post
Re: Weird linking error on wxSmith plugin on Windows
« Reply #2 on: July 20, 2016, 05:12:11 pm »
Commenting out the "#undef _UNICODE" fixed the wxSmith Plugin; just noticed I was missing the n in "#ifndef".
Edit: Some of my past trial fixes broke the CB Core Project; so, I am rebuilding that and wxSmith to test.

The root problem on windows is the including of the header "windows.h" with _UNICODE undefined.
I have yet to locate that include on my computer; might be in my Compiler.
If this does NOT work will see if an TDM MinGW GCC compiler has the issue.

Code
diff --git a/src/include/scripting/sqplus/sqplus.h b/src/include/scripting/sqplus/sqplus.h
index 4817b1c..681783e 100644
--- a/src/include/scripting/sqplus/sqplus.h
+++ b/src/include/scripting/sqplus/sqplus.h
@@ -47,9 +47,12 @@
 #define SQ_CALL_RAISE_ERROR SQFalse
 #endif
 
+// C::B patch: undef of "_UNICODE"
 // this does the same as commenting out the "#ifdef _UNICODE"-stuff in our
 // bundled squirrel.h, but works also for system-squirrel
+#ifndef __WXMSW__
 #undef _UNICODE
+#endif
 #include "squirrel.h"
 
 // C::B patch: so it builds on 64bit, ecapsulate bool/int/float using Squirrel types (this patch applies everywhere, where threse types are used)
« Last Edit: July 20, 2016, 05:14:09 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Online stahta01

  • Lives here!
  • ****
  • Posts: 7589
    • My Best Post
Re: Weird linking error on wxSmith plugin on Windows
« Reply #3 on: July 20, 2016, 05:47:17 pm »
Yes, Adding the n to "#ifndef" fixed the build issue; I was just too tired yesterday.

Now I am building the "CodeBlocks.workspace" to verify the other plugins still build.
Edit: The other plugins all built without linker errors.

Tim S.
« Last Edit: July 20, 2016, 06:54:53 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Online stahta01

  • Lives here!
  • ****
  • Posts: 7589
    • My Best Post
Re: Weird linking error on wxSmith plugin on Windows
« Reply #4 on: July 20, 2016, 07:30:58 pm »
The wxSmith Compiler error that my patch above fixes.

Code
-------------- Build: wxSmithLib in wxSmith (compiler: GNU GCC Compiler)---------------

i686-w64-mingw32-g++.exe -Wall -g -pipe -mthreads -fmessage-length=0 -fexceptions -Winvalid-pch -Wno-attributes -DHAVE_W32API_H -D__WXMSW__ -DWXUSINGDLL -DcbDEBUG -DCB_PRECOMP -DWX_PRECOMP -DBUILDING_PLUGIN -DwxUSE_UNICODE -std=gnu++11 -Wno-deprecated-declarations -Wno-unused-local-typedefs -IC:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\lib\gcc_dll\mswu -IC:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include -I..\..\..\include -I..\..\..\include\tinyxml -I..\..\..\sdk\wxpropgrid\include -I..\..\..\sdk\wxscintilla\include -I..\..\..\include\scripting\include -I..\..\..\include\scripting\squirrel -I..\..\..\include\scripting\sqplus -I..\..\..\include\scripting\bindings -I..\..\..\include\mozilla_chardet -I..\..\..\include\mozilla_chardet\mfbt -I..\..\..\include\mozilla_chardet\nsprpub\pr\include -I..\..\..\include\mozilla_chardet\xpcom -I..\..\..\include\mozilla_chardet\xpcom\base -I..\..\..\include\mozilla_chardet\xpcom\glue -c C:\Devel\open_source_code\version_control\codeblocks_custom_build-git\src\plugins\contrib\wxSmith\wxsmith.cpp -o ..\..\..\.objs\plugins\contrib\wxSmithLib\wxsmith.o
In file included from C:/Apps32/MSys2/mingw32/i686-w64-mingw32/include/windows.h:72:0,
                 from C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/msw/wrapwin.h:51,
                 from C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/fontutil.h:26,
                 from C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/fontmap.h:24,
                 from ..\..\..\include/cbeditor.h:11,
                 from ..\..\..\include\scripting\bindings/sc_base_types.h:26,
                 from C:\Devel\open_source_code\version_control\codeblocks_custom_build-git\src\plugins\contrib\wxSmith\wxsmith.cpp:39:
C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/msw/winundef.h: In function 'HWND__* CreateDialog(HINSTANCE, LPCTSTR, HWND, DLGPROC)':
C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/msw/winundef.h:41:20: error: cannot convert 'LPCTSTR {aka const wchar_t*}' to 'LPCSTR {aka const char*}' for argument '2' to 'HWND__* CreateDialogParamA(HINSTANCE, LPCSTR, HWND, DLGPROC, LPARAM)'
             return CreateDialogA(hInstance, pTemplate, hwndParent, pDlgProc);
                    ^
In file included from C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/msw/wrapwin.h:58:0,
                 from C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/fontutil.h:26,
                 from C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/fontmap.h:24,
                 from ..\..\..\include/cbeditor.h:11,
                 from ..\..\..\include\scripting\bindings/sc_base_types.h:26,
                 from C:\Devel\open_source_code\version_control\codeblocks_custom_build-git\src\plugins\contrib\wxSmith\wxsmith.cpp:39:
C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/msw/winundef.h: In function 'HFONT__* CreateFont(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCTSTR)':
C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/msw/winundef.h:75:48: error: cannot convert 'LPCTSTR {aka const wchar_t*}' to 'LPCSTR {aka const char*}' for argument '14' to 'HFONT__* CreateFontA(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCSTR)'
                                family, facename);
                                                ^
In file included from C:/Apps32/MSys2/mingw32/i686-w64-mingw32/include/windows.h:72:0,
                 from C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/msw/wrapwin.h:51,
                 from C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/fontutil.h:26,
                 from C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/fontmap.h:24,
                 from ..\..\..\include/cbeditor.h:11,
                 from ..\..\..\include\scripting\bindings/sc_base_types.h:26,
                 from C:\Devel\open_source_code\version_control\codeblocks_custom_build-git\src\plugins\contrib\wxSmith\wxsmith.cpp:39:
C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/msw/winundef.h: In function 'HWND__* CreateWindow(LPCTSTR, LPCTSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID)':
C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/msw/winundef.h:98:20: error: cannot convert 'LPCTSTR {aka const wchar_t*}' to 'LPCSTR {aka const char*}' for argument '2' to 'HWND__* CreateWindowExA(DWORD, LPCSTR, LPCSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID)'
             return CreateWindowA(lpClassName, lpWndClass, dwStyle, x, y, w, h,
                    ^
In file included from C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/msw/wrapwin.h:58:0,
                 from C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/fontutil.h:26,
                 from C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/fontmap.h:24,
                 from ..\..\..\include/cbeditor.h:11,
                 from ..\..\..\include\scripting\bindings/sc_base_types.h:26,
                 from C:\Devel\open_source_code\version_control\codeblocks_custom_build-git\src\plugins\contrib\wxSmith\wxsmith.cpp:39:
C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/msw/winundef.h: In function 'HMENU__* LoadMenu(HINSTANCE, LPCTSTR)':
C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/msw/winundef.h:114:44: error: cannot convert 'LPCTSTR {aka const wchar_t*}' to 'LPCSTR {aka const char*}' for argument '2' to 'HMENU__* Load
MenuA(HINSTANCE, LPCSTR)'
             return LoadMenuA(instance, name);
                                            ^
C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/msw/winundef.h: In function 'HICON__* LoadIcon(HINSTANCE, LPCTSTR)':
C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/msw/winundef.h:320:51: error: cannot convert 'LPCTSTR {aka const wchar_t*}' to 'LPCSTR {aka const char*}' for argument '2' to 'HICON__* LoadIconA(HINSTANCE, LPCSTR)'
             return LoadIconA(hInstance, lpIconName);
                                                   ^
C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/msw/winundef.h: In function 'HBITMAP__* LoadBitmap(HINSTANCE, LPCTSTR)':
C:\Devel\open_source_code\no_version_control\wxMSW-2.8\wxMSW-2.8.12_Msys2\include/wx/msw/winundef.h:333:55: error: cannot convert 'LPCTSTR {aka const wchar_t*}' to 'LPCSTR {aka const char*}' for argument '2' to 'HBITMAP__* LoadBitmapA(HINSTANCE, LPCSTR)'
             return LoadBitmapA(hInstance, lpBitmapName);
                                                       ^
Process terminated with status 1 (0 minute(s), 30 second(s))
6 error(s), 0 warning(s) (0 minute(s), 30 second(s))

NOTE: The normal fix of this type of error of this code below; only changed the compiler error into a linker error!
Code
//
// Added to top of wxsmith.cpp and wxwidgets/wxwidgetsresfactory.cpp files.
//
#ifdef __WXMSW__
#include <wx/msw/wrapwin.h>  // includes <windows.h>
#endif
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Weird linking error on wxSmith plugin on Windows
« Reply #5 on: July 21, 2016, 02:43:25 pm »
Should be fixed in trunk, thanks Tim.
My fix is slightly different to yours and undefines _UNICODE only when including squirrel.h from our sources.

It works on Fedora 24 64 bit with ggcc 6.1, wx2.8.12 and wxsvn  and also on Win10 with wx2.8.12 and gcc4.8.
Neither with gcc64 on windows, nor with wx30 on windows

Online stahta01

  • Lives here!
  • ****
  • Posts: 7589
    • My Best Post
Re: Weird linking error on wxSmith plugin on Windows
« Reply #6 on: July 21, 2016, 10:52:55 pm »
Should be fixed in trunk, thanks Tim.
My fix is slightly different to yours and undefines _UNICODE only when including squirrel.h from our sources.

It works on Fedora 24 64 bit with ggcc 6.1, wx2.8.12 and wxsvn  and also on Win10 with wx2.8.12 and gcc4.8.
Neither with gcc64 on windows, nor with wx30 on windows

It built without error on Windows 7 [32 bit] using wxWidgets 2.8.12 using MSys2 GCC Compiler.
Edit: gcc version 5.3.0 (Rev5, Built by MSYS2 project)

Tim S.
« Last Edit: July 21, 2016, 11:06:03 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org