Cross Compiling under Linux to WIndows using MinGW Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
LsDevs
Knows some wx things
Knows some wx things
Posts: 31
Joined: Fri Feb 28, 2020 8:23 am

Cross Compiling under Linux to WIndows using MinGW

Post by LsDevs » Fri Feb 28, 2020 8:53 am

Hi,
I'm new to wxWidgets and I'm learning it.
I followed the Hello World tutorial and it works great.
So now, I would like to cross compile it for Windows. I've followed the instructions on wxWidgets wiki : downloaded the source files, compiled it using

Code: Select all

./configure --prefix=/usr/x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --build=x86_64-linux && make && sudo make install
I use CLion IDE and it use CMake, so I changed my CMakeList;Txt to :

Code: Select all

cmake_minimum_required(VERSION 3.15)
project(wxWidgets)

set(CMAKE_CXX_STANDARD 20)
find_package(wxWidgets REQUIRED COMPONENTS net core base)
include(${wxWidgets_USE_FILE})
if(WIN32)
    set(SRCS ${SRCS} minimal.rc)
endif(WIN32)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
add_executable(wxWidgets WIN32 main.cpp)
target_link_libraries(wxWidgets ${wxWidgets_LIBRARIES})
I got some errors compiling it (Missing headers file I think)
I not very friendly with CMake and particularly with importing and linking externals libraries....

Here you can see the errors :

Code: Select all

In file included from /usr/include/wx-3.0/wx/defs.h:27,
                 from /usr/include/wx-3.0/wx/wxprec.h:12,
                 from /home/ubuntu/Dev/C++/wxWidgets/main.cpp:3:
/usr/include/wx-3.0/wx/platform.h:438:13: fatal error: wx/msw/libraries.h: No such file or folder
  438 | #   include "wx/msw/libraries.h"
      |             ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/wxWidgets.dir/build.make:63: CMakeFiles/wxWidgets.dir/main.cpp.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:76: CMakeFiles/wxWidgets.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/wxWidgets.dir/rule] Error 2
make: *** [Makefile:118: wxWidgets] Error 2

I really don't understand what I'm doing wrong or what am I am missing.

I would like to notice that I have a Windows computer too and I could easily jump into windows and compile it here. But this is not my goal I really want to understand how the process of linking and cross-compiling works.
I would appreciate any help.

Thanks, Laurent.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3893
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Cross Compiling under Linux to WIndows using MinGW

Post by ONEEYEMAN » Fri Feb 28, 2020 7:41 pm

Hi,
LsDevs wrote:
Fri Feb 28, 2020 8:53 am
Hi,
I'm new to wxWidgets and I'm learning it.
I followed the Hello World tutorial and it works great.
So now, I would like to cross compile it for Windows. I've followed the instructions on wxWidgets wiki : downloaded the source files, compiled it using

Code: Select all

./configure --prefix=/usr/x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --build=x86_64-linux && make && sudo make install
I think you need to add "--with-msw" to the configure line.
LsDevs wrote:
Fri Feb 28, 2020 8:53 am
I use CLion IDE and it use CMake, so I changed my CMakeList;Txt to :

Code: Select all

cmake_minimum_required(VERSION 3.15)
project(wxWidgets)

set(CMAKE_CXX_STANDARD 20)
find_package(wxWidgets REQUIRED COMPONENTS net core base)
include(${wxWidgets_USE_FILE})
if(WIN32)
    set(SRCS ${SRCS} minimal.rc)
endif(WIN32)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
add_executable(wxWidgets WIN32 main.cpp)
target_link_libraries(wxWidgets ${wxWidgets_LIBRARIES})
I got some errors compiling it (Missing headers file I think)
I not very friendly with CMake and particularly with importing and linking externals libraries....

Here you can see the errors :

Code: Select all

In file included from /usr/include/wx-3.0/wx/defs.h:27,
                 from /usr/include/wx-3.0/wx/wxprec.h:12,
                 from /home/ubuntu/Dev/C++/wxWidgets/main.cpp:3:
/usr/include/wx-3.0/wx/platform.h:438:13: fatal error: wx/msw/libraries.h: No such file or folder
  438 | #   include "wx/msw/libraries.h"
      |             ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/wxWidgets.dir/build.make:63: CMakeFiles/wxWidgets.dir/main.cpp.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:76: CMakeFiles/wxWidgets.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/wxWidgets.dir/rule] Error 2
make: *** [Makefile:118: wxWidgets] Error 2

I really don't understand what I'm doing wrong or what am I am missing.

I would like to notice that I have a Windows computer too and I could easily jump into windows and compile it here. But this is not my goal I really want to understand how the process of linking and cross-compiling works.
I would appreciate any help.

Thanks, Laurent.

Post Reply