← Back to team overview

kicad-developers team mailing list archive

Re: PATCH: fix kicad2step non-ASCII filename problem in MinGW

 

Further to my previous post, I found I can build a working kicad2step
using the wxIMPLEMENT_APP_CONSOLE macro after

(a) applying the attached patch to the wxWidgets includes
(b) Adding the following line to (kicad) utils/kicad2step/CMakeLists.txt:

set_target_properties( kicad2step PROPERTIES LINK_FLAGS "${LINK_FLAGS}
-municode")

If any wx gurus out there would care to have a look at the wx patch
and confirm that the problem is with upstream wx, that would be
appreciated. I'd rather use the CONSOLE version of the macro in
order to skip some GUI-specific initializations, though in practice
it's not an intolerable overhead.

- Cirilo

On Sun, Mar 5, 2017 at 3:52 PM, Cirilo Bernardo
<cirilo.bernardo@xxxxxxxxx> wrote:
> This patch fixes the non-ASCII filename problem in
> Windows+MinGW.
>
> When this patch is applied, and OCE is built under
> MinGW with the patch I previously supplied, all
> 3D model viewing and STEP export appear to work
> mostly as expected. There is one remaining
> issue to resolve which is correctly passing the
> UTF8 filename from pcbnew to kicad2step and
> ensuring that the appropriate output file is created.
> At the moment I'm not sure if the problem is in
> kicad2step or my hack of OCE, but I'm looking
> into it.
>
> - Cirilo
diff --git a/include/wx/app.h b/include/wx/app.h
index 9a73469570..ed37dcf38d 100644
--- a/include/wx/app.h
+++ b/include/wx/app.h
@@ -790,7 +790,7 @@ public:
 // For compilers that support it, prefer to use wmain() as this ensures any
 // Unicode strings can be passed as command line parameters and not just those
 // representable in the current locale.
-#if wxUSE_UNICODE && defined(__VISUALC__)
+#if wxUSE_UNICODE && ( defined(__VISUALC__) || defined(__MINGW32__) || defined(__MINGW64__) )
     #define wxIMPLEMENT_WXWIN_MAIN_CONSOLE                                    \
         int wmain(int argc, wchar_t **argv)                                   \
         {                                                                     \
diff --git a/include/wx/msw/init.h b/include/wx/msw/init.h
index 014dedbd09..e36474ca09 100644
--- a/include/wx/msw/init.h
+++ b/include/wx/msw/init.h
@@ -70,6 +70,25 @@ extern WXDLLIMPEXP_CORE int
     #define wxIMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD
 #endif // defined(__BORLANDC__) && wxUSE_UNICODE
 
+
+#if ( defined(__MINGW64__) || defined(__MINGW32__) ) && wxUSE_UNICODE
+#define wxIMPLEMENT_WXWIN_MAIN                                              \
+    extern "C" int WINAPI wWinMain(HINSTANCE hInstance,                     \
+                                  HINSTANCE hPrevInstance,                  \
+                                  wxCmdLineArgType WXUNUSED(lpCmdLine),     \
+                                  int nCmdShow)                             \
+    {                                                                       \
+        wxDISABLE_DEBUG_SUPPORT();                                          \
+                                                                            \
+        /* NB: We pass NULL in place of lpCmdLine to behave the same as  */ \
+        /*     Borland-specific wWinMain() above. If it becomes needed   */ \
+        /*     to pass lpCmdLine to wxEntry() here, you'll have to fix   */ \
+        /*     wWinMain() above too.                                     */ \
+        return wxEntry(hInstance, hPrevInstance, NULL, nCmdShow);           \
+    }                                                                       \
+
+#else
+
 #define wxIMPLEMENT_WXWIN_MAIN                                              \
     extern "C" int WINAPI WinMain(HINSTANCE hInstance,                      \
                                   HINSTANCE hPrevInstance,                  \
@@ -86,5 +105,6 @@ extern WXDLLIMPEXP_CORE int
     }                                                                       \
     wxIMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD
 
+#endif
 
 #endif // _WX_MSW_INIT_H_

References