Cross Compile to Windows from Linux with wxWidgets

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
kurizu
In need of some credit
In need of some credit
Posts: 5
Joined: Thu May 25, 2017 2:42 pm

Cross Compile to Windows from Linux with wxWidgets

Post by kurizu »

So, I guess I should start by mentioning that I am new to wxWidgets. After following a couple of demos and tutorials, I was able to build a simple GUI with several boxes and buttons with wxWidgets in C++. I'm developing on Linux under Ubuntu 16.04 LTS and have been able to successfully run my code within Linux. Given that I've got the GUI working on Linux, I really want to port it to Windows since I need to do cross-platform development. Unfortunately, I haven't been able to make much progress on this. I downloaded MinGW and was able to make simple executables in C++ that worked on my Windows computer but once I try to compile and export my C++ program with the wxWidgets library, everything goes downhill. The first time I tried cross-compiling I found out that I lacked the wx/msw library (tried to access libraries.h file) so I added that to my wx folder. However, after fixing that, I received a slew of several other errors (none of which were fatal but my executable still wasn't generated). Any help with figuring out how to cross-compile my C++ to Windows from Linux would be greatly appreciated! Even just a working starting point would be helpful.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Cross Compile to Windows from Linux with wxWidgets

Post by ONEEYEMAN »

Hi,
What errors did you receive?

Also, I presume you were working with the wxGTK that you installed from the repository of Ubuntu?
Just download the whole source code and try to compile again.

Thank you.
kurizu
In need of some credit
In need of some credit
Posts: 5
Joined: Thu May 25, 2017 2:42 pm

Re: Cross Compile to Windows from Linux with wxWidgets

Post by kurizu »

I don't believe I've setup wxGTK. I can try installing that and see what happens afterwards. It sounds like wxGTK is necessary for this I'm guessing. In the meantime, here's the command I ran:
/opt/mingw64/bin/x86_64-w64-mingw32-g++ ./guiProto.cpp `wx-config --cxxflags --libs` -o ~/test.exe

I've attached the error outputs at .txt file to this message since it's rather long.
Attachments
error.txt
Error Messages
(14.23 KiB) Downloaded 226 times
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Cross Compile to Windows from Linux with wxWidgets

Post by ONEEYEMAN »

Hi,
It probably being installed from the repository at one point.
But don't install it - like I said grab the whole source from the wxwidgets.org and try to compile the library first.

BTW, you do understand you need to compile the library with the Windows SDK and then compile the application with Windows-based wx libraries? And then you will need to copy the libraries and the executable to the Windows machine to test.

Thank you.
kurizu
In need of some credit
In need of some credit
Posts: 5
Joined: Thu May 25, 2017 2:42 pm

Re: Cross Compile to Windows from Linux with wxWidgets

Post by kurizu »

Thanks for the continue help, I appreciate it. So, I'm also kinda new to adding external libraries to C++ (especially through terminal). If I understand correctly, you're suggesting that I download the source code for wxGtk from wxwidgets.org github repository and then compile that source code. How exactly would I compile that source code and link it to my wxWidgets library being used in .cpp file?

As for the Windows SDK and wx libraries, I know that add the wx/msw libraries to support Windows in the wx libraries. Would the Windows SDK be included in that as well or would that be separate?

I apologize if I'm inadvertently making this more complicated than it should be...
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Cross Compile to Windows from Linux with wxWidgets

Post by doublemax »

Just for clarification: Do you really want to "cross-compile"? Cross-compiling means that you compile under Linux, but create a Windows executable in the process.

Or you do you just want to carry your project that already works under Linux, over to a Windows machine and build it there?
Use the source, Luke!
kurizu
In need of some credit
In need of some credit
Posts: 5
Joined: Thu May 25, 2017 2:42 pm

Re: Cross Compile to Windows from Linux with wxWidgets

Post by kurizu »

Yes, I definitely intend to cross-compile. I am developing my code on my own Linux computer but I'm designing a program that needs to be used on several different OSs when deployed. Since I also have a PC, I am trying to start by deploying my code developed on Linux to an executable file that Windows can run. I intend to write code on Linux and then deploy that code to Windows (and hopefully OSX later down the road) as executable programs.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Cross Compile to Windows from Linux with wxWidgets

Post by ONEEYEMAN »

Hi,
So are you going to set up a VM with Windows or you already have a machine that runs Windows? Because you will need that for testing...

Anyway I didn't say to download wxGTK. I said to download the whole wxWidgets source code.
But it would be much easier and simpler to just move to Windows, whether in a VM or not and compile everything there.

The process is simple:

1 Download MSVC Express (any version will do - Express means it is free) and install it or
1 Download MinGW compiler and install it
2 Download wxWidgets-3.0.3/wxWidgets-3.1 and unpack it somewhere (i.e. in c:\wxWidgets)
3 For MSVC open the IDE and then do "File->Open...->Project/Solution" navigate to c:\wxWIdgets\build\msw and open the appropriate project/solution, then select "Build->Batch Build..." and click "Build All".
3 For MinGW, open the Command Prompt, navigate to c:\wxWIdgets\build\mszw and then type: "mingw32 -f Makefile.gcc DEBUG=1".
4. Compile you project.
5 Execute the binary.

Thank you.
kurizu
In need of some credit
In need of some credit
Posts: 5
Joined: Thu May 25, 2017 2:42 pm

Re: Cross Compile to Windows from Linux with wxWidgets

Post by kurizu »

Thanks for all of the advice everyone. In the end, I decided to pursue my project in Java for a variety of reasons (e.g. it's more familiar, easier to port to multiple OS, etc). I'll definitely revisit the suggestions listed here if I end up looking into wxWidgets again in the future.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Cross Compile to Windows from Linux with wxWidgets

Post by ONEEYEMAN »

Good luck.
stahta01
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 548
Joined: Fri Nov 03, 2006 2:00 pm

Re: Cross Compile to Windows from Linux with wxWidgets

Post by stahta01 »

kurizu wrote:Thanks for all of the advice everyone. In the end, I decided to pursue my project in Java for a variety of reasons (e.g. it's more familiar, easier to port to multiple OS, etc). I'll definitely revisit the suggestions listed here if I end up looking into wxWidgets again in the future.
Please report back if this saying is true or not?
Java build once, debug everywhere
Tim S.
Post Reply