Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when building this library wxWidgets support under msys2, I got build error, here is a patch to fix the error #210

Open
asmwarrior opened this issue Aug 4, 2023 · 0 comments

Comments

@asmwarrior
Copy link

Hi, I'm building this library with such cmake option below, note that wxWidgets gui option is ON.
I am using this library under msys2:

cmake .. -G "MinGW Makefiles" -DVL_GUI_WIN32_SUPPORT=ON -DVL_GUI_WIN32_EXAMPLES=ON -DVL_GUI_WXWIDGETS_SUPPORT=ON -DVL_GUI_WXWIDGETS_EXAMPLES=ON-DVL_INSTALL_DATA=ON -DCMAKE_INSTALL_PREFIX='F:\code\VisualizationLibrary\buildwx\install\'

When I run the command mingw32-make.exe

I got such build error:

[ 81%] Building CXX object src/gui/vlWX/CMakeFiles/VLWX.dir/WXGLCanvas.cpp.obj
In file included from F:/code/msys2-64/mingw64/include/windows.h:72,
                 from F:/code/VisualizationLibrary/src/vlCore/checks.hpp:45,
                 from F:/code/VisualizationLibrary/src/vlCore/Object.hpp:35,
                 from F:/code/VisualizationLibrary/src/vlGraphics/OpenGLContext.hpp:35,
                 from F:/code/VisualizationLibrary/src/gui/vlWX/WXGLCanvas.hpp:36,
                 from F:\code\VisualizationLibrary\src\gui\vlWX\WXGLCanvas.cpp:32:
F:/code/msys2-64/mingw64/include/wx-3.2/wx/msw/winundef.h: In function 'HWND__* CreateDialog(HINSTANCE, LPCTSTR, HWND, DLGPROC)':
F:/code/msys2-64/mingw64/include/wx-3.2/wx/msw/winundef.h:48:20: error: cannot convert 'LPCTSTR' {aka 'const wchar_t*'} to 'LPCSTR' {aka 'const char*'}
   48 |             return CreateDialogA(hInstance, pTemplate, hwndParent, pDlgProc);
      |                    ^~~~~~~~~~~~~
      |                    |
      |                    LPCTSTR {aka const wchar_t*}
F:/code/msys2-64/mingw64/include/winuser.h:2404:72: note:   initializing argument 2 of 'HWND__* CreateDialogParamA(HINSTANCE, LPCSTR, HWND, DLGPROC, LPARAM)'
 2404 |   WINUSERAPI HWND WINAPI CreateDialogParamA(HINSTANCE hInstance,LPCSTR lpTemplateName,HWND hWndParent,DLGPROC lpDialogFunc,LPARAM dwInitParam);
      |                                                                 ~~~~~~~^~~~~~~~~~~~~~
In file included from F:/code/msys2-64/mingw64/include/wx-3.2/wx/defs.h:33,
                 from F:/code/msys2-64/mingw64/include/wx-3.2/wx/event.h:14,
                 from F:/code/msys2-64/mingw64/include/wx-3.2/wx/window.h:18,
                 from F:/code/msys2-64/mingw64/include/wx-3.2/wx/nonownedwnd.h:14,
                 from F:/code/msys2-64/mingw64/include/wx-3.2/wx/toplevel.h:20,
                 from F:/code/msys2-64/mingw64/include/wx-3.2/wx/frame.h:18,
                 from F:/code/VisualizationLibrary/src/gui/vlWX/WXGLCanvas.hpp:38:
F:/code/msys2-64/mingw64/include/wx-3.2/wx/msw/winundef.h: In function 'HFONT__* CreateFont(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCTSTR)':
F:/code/msys2-64/mingw64/include/wx-3.2/wx/msw/winundef.h:82:40: error: cannot convert 'LPCTSTR' {aka 'const wchar_t*'} to 'LPCSTR' {aka 'const char*'}
   82 |                                family, facename);
      |                                        ^~~~~~~~
      |                                        |
      |                                        LPCTSTR {aka const wchar_t*}
In file included from F:/code/msys2-64/mingw64/include/windows.h:71:
F:/code/msys2-64/mingw64/include/wingdi.h:2809:254: note:   initializing argument 14 of 'HFONT__* CreateFontA(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCSTR)'
 2809 |   WINGDIAPI HFONT WINAPI CreateFontA(int cHeight,int cWidth,int cEscapement,int cOrientation,int cWeight,DWORD bItalic,DWORD bUnderline,DWORD bStrikeOut,DWORD iCharSet,DWORD iOutPrecision,DWORD iClipPrecision,DWORD iQuality,DWORD iPitchAndFamily,LPCSTR pszFaceName);
      |                                                                                                                                                                                                                                                       ~~~~~~~^~~~~~~~~~~
F:/code/msys2-64/mingw64/include/wx-3.2/wx/msw/winundef.h: In function 'HWND__* CreateWindow(LPCTSTR, LPCTSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID)':
F:/code/msys2-64/mingw64/include/wx-3.2/wx/msw/winundef.h:105:20: error: cannot convert 'LPCTSTR' {aka 'const wchar_t*'} to 'LPCSTR' {aka 'const char*'}
  105 |             return CreateWindowA(lpClassName, lpWndClass, dwStyle, x, y, w, h,
      |                    ^~~~~~~~~~~~~
      |                    |
      |                    LPCTSTR {aka const wchar_t*}
F:/code/msys2-64/mingw64/include/winuser.h:2203:65: note:   initializing argument 2 of 'HWND__* CreateWindowExA(DWORD, LPCSTR, LPCSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID)'
 2203 |   WINUSERAPI HWND WINAPI CreateWindowExA(DWORD dwExStyle,LPCSTR lpClassName,LPCSTR lpWindowName,DWORD dwStyle,int X,int Y,int nWidth,int nHeight,HWND hWndParent,HMENU hMenu,HINSTANCE hInstance,LPVOID lpParam);
      |                                                          ~~~~~~~^~~~~~~~~~~
F:/code/msys2-64/mingw64/include/wx-3.2/wx/msw/winundef.h: In function 'HMENU__* LoadMenu(HINSTANCE, LPCTSTR)':
F:/code/msys2-64/mingw64/include/wx-3.2/wx/msw/winundef.h:121:40: error: cannot convert 'LPCTSTR' {aka 'const wchar_t*'} to 'LPCSTR' {aka 'const char*'}
  121 |             return LoadMenuA(instance, name);
      |                                        ^~~~
      |                                        |
      |                                        LPCTSTR {aka const wchar_t*}
F:/code/msys2-64/mingw64/include/winuser.h:3261:64: note:   initializing argument 2 of 'HMENU__* LoadMenuA(HINSTANCE, LPCSTR)'
 3261 |   WINUSERAPI HMENU WINAPI LoadMenuA(HINSTANCE hInstance,LPCSTR lpMenuName);
      |                                                         ~~~~~~~^~~~~~~~~~
F:/code/msys2-64/mingw64/include/wx-3.2/wx/msw/winundef.h: In function 'HICON__* LoadIcon(HINSTANCE, LPCTSTR)':
F:/code/msys2-64/mingw64/include/wx-3.2/wx/msw/winundef.h:312:41: error: cannot convert 'LPCTSTR' {aka 'const wchar_t*'} to 'LPCSTR' {aka 'const char*'}
  312 |             return LoadIconA(hInstance, lpIconName);
      |                                         ^~~~~~~~~~
      |                                         |
      |                                         LPCTSTR {aka const wchar_t*}
F:/code/msys2-64/mingw64/include/winuser.h:4158:64: note:   initializing argument 2 of 'HICON__* LoadIconA(HINSTANCE, LPCSTR)'
 4158 |   WINUSERAPI HICON WINAPI LoadIconA(HINSTANCE hInstance,LPCSTR lpIconName);
      |                                                         ~~~~~~~^~~~~~~~~~
F:/code/msys2-64/mingw64/include/wx-3.2/wx/msw/winundef.h: In function 'HBITMAP__* LoadBitmap(HINSTANCE, LPCTSTR)':
F:/code/msys2-64/mingw64/include/wx-3.2/wx/msw/winundef.h:325:43: error: cannot convert 'LPCTSTR' {aka 'const wchar_t*'} to 'LPCSTR' {aka 'const char*'}
  325 |             return LoadBitmapA(hInstance, lpBitmapName);
      |                                           ^~~~~~~~~~~~
      |                                           |
      |                                           LPCTSTR {aka const wchar_t*}
F:/code/msys2-64/mingw64/include/winuser.h:4111:68: note:   initializing argument 2 of 'HBITMAP__* LoadBitmapA(HINSTANCE, LPCSTR)'
 4111 |   WINUSERAPI HBITMAP WINAPI LoadBitmapA(HINSTANCE hInstance,LPCSTR lpBitmapName);
      |                                                             ~~~~~~~^~~~~~~~~~~~
F:\code\VisualizationLibrary\src\gui\vlWX\WXGLCanvas.cpp: In member function 'void vlWX::WXGLCanvas::OnIdle(wxIdleEvent&)':
F:\code\VisualizationLibrary\src\gui\vlWX\WXGLCanvas.cpp:102:38: warning: unused parameter 'ev' [-Wunused-parameter]
  102 | void WXGLCanvas::OnIdle(wxIdleEvent& ev)
      |                         ~~~~~~~~~~~~~^~
mingw32-make[2]: *** [src\gui\vlWX\CMakeFiles\VLWX.dir\build.make:76: src/gui/vlWX/CMakeFiles/VLWX.dir/WXGLCanvas.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:904: src/gui/vlWX/CMakeFiles/VLWX.dir/all] Error 2
mingw32-make: *** [Makefile:155: all] Error 2

You can see, it looks like the ANSI (non-Unicode) version of the Windows API is used.

To solve this issue, I have such patch:

diff --git a/src/gui/vlWX/WXGLCanvas.hpp b/src/gui/vlWX/WXGLCanvas.hpp
index 4b555e01..cf0a931f 100644
--- a/src/gui/vlWX/WXGLCanvas.hpp
+++ b/src/gui/vlWX/WXGLCanvas.hpp
@@ -32,15 +32,16 @@
 #ifndef vlWXGLCanvas_INCLUDE_ONCE
 #define vlWXGLCanvas_INCLUDE_ONCE
 
-#include <vlWX/link_config.hpp>
-#include <vlGraphics/OpenGLContext.hpp>
-#include <vlCore/Time.hpp>
 #include <wx/frame.h>
 #include <wx/glcanvas.h>
 #include <wx/timer.h>
 #include <wx/dcclient.h>
 #include <wx/image.h>
 #include <wx/app.h>
+#include <vlWX/link_config.hpp>
+#include <vlGraphics/OpenGLContext.hpp>
+#include <vlCore/Time.hpp>
+
 
 #if !wxUSE_GLCANVAS
   #error "OpenGL required: set wxUSE_GLCANVAS to 1 and rebuild the library"

The patch is very simple, I just put the wxWidgets related header files before the vl related header files, because the wxWidgets header files may already set the unicode preprocessor correctly.

BTW: the wx library version 3.2.2.1 is already installed by the pacman command under msys2, see here:
Package: mingw-w64-x86_64-wxwidgets3.2-msw - MSYS2 Packages

asmwarrior added a commit to asmwarrior/VisualizationLibrary that referenced this issue Aug 4, 2023
see discussion here:
when building this library wxWidgets support under msys2, I got build error, here is a patch to fix the error
Issue MicBosi#210 · MicBosi/VisualizationLibrary — MicBosi#210
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant