How to port my Linux WX app to Windows?

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
kornerr
Experienced Solver
Experienced Solver
Posts: 66
Joined: Wed Oct 12, 2005 2:43 pm
Location: Russia
Contact:

How to port my Linux WX app to Windows?

Post by kornerr »

I have an OpenGL WX app in Linux. How to port it to Windows?

Thanks.
Open Source all the way, baby ;)
OpenGameStudio
Image
User avatar
T-Rex
Moderator
Moderator
Posts: 1249
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Post by T-Rex »

If your project doesn't contain platform-specific code then you should just create new project using MS VC++ Express (which is free) or wxDev-CPP or othe IDE for Windows, add all your source code to this project (http://forums.wxwidgets.org/viewtopic.php?t=255) and it should work.
Also if you have platform-specific code then you should use #ifdef

#ifdef __WXGTK__
// GTK-specific code
#else
// e.g. Win32-specific code
#endif
kornerr
Experienced Solver
Experienced Solver
Posts: 66
Joined: Wed Oct 12, 2005 2:43 pm
Location: Russia
Contact:

Post by kornerr »

Thanks, T-Rex.
One more question. Will my ported app be dependend on wx lib? I.e. will I be able to run it on Windows without wx installed?

Thanks.
Open Source all the way, baby ;)
OpenGameStudio
Image
priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia »

kornerr wrote:Thanks, T-Rex.
One more question. Will my ported app be dependend on wx lib? I.e. will I be able to run it on Windows without wx installed?

Thanks.
Static link the wx libraries then you won't need the wx installed on other systems where you deploy your applications
kornerr
Experienced Solver
Experienced Solver
Posts: 66
Joined: Wed Oct 12, 2005 2:43 pm
Location: Russia
Contact:

Post by kornerr »

Static link the wx libraries
How to do it?

BTW, I've compiled small app using MinGW and it is of 22M! While in Linux it has 150K! What's wrong here?

Thanks.
Open Source all the way, baby ;)
OpenGameStudio
Image
Ksmith22
I live to help wx-kind
I live to help wx-kind
Posts: 199
Joined: Mon Nov 21, 2005 4:34 pm

Post by Ksmith22 »

kornerr wrote:Thanks, T-Rex.
One more question. Will my ported app be dependend on wx lib? I.e. will I be able to run it on Windows without wx installed?

Thanks.
Like priyank_bolia said, you will need to link the widget libraries ("install them") to compile on Windows. You will not need them to run the executable. So if you distribute the EXE to anyone else, they will not need wxWidgets at all to run it.

As for how to link them it depends on your compiler but I believe there are a number of tutorials around the wxWidgets homepage and probably these forums for different compilers. I've only had experience with Visual C++ but for that at least wxWidgets provides a pre-made project file that I just have to open up and build. It's pretty simple (though setting up the environments for my apps is not quite as easy :)).

22MB sounds wrong though. I don't know what you did there but the files shouldn't be that large unless your app is absolutely massive (which at 150k on Linux it shouldn't be). That could also be an issue with MinGW, I've never used it myself.
toxicBunny
Super wx Problem Solver
Super wx Problem Solver
Posts: 424
Joined: Tue Jul 12, 2005 8:44 pm
Location: Alabama, USA

Post by toxicBunny »

There are a lot of tips around for reducing the size of executable files built with wxWidgets. Just search the forum or the web...

In your case, you're most likely linking with wxWidgets as a shared library under linux and a static library under Windows. This means that all of the wxWidgets code will be linked with your Windows app. You can also build the wxWidgets libraries as shared libraries and simply place them in your application folder when you distribute the app. This means the user doesn't have to install wxWidgets separately and your executable will be much smaller. However, you then have the extra size of the wxWidgets DLLs. It's really up to you...

Mingw generally produces much larger executable files than the Microsoft or Borland compilers. I'd say you could work with Mingw until you're ready to release your app, and then get the free Visual C++ Express to compile the release version.

-Scott
User avatar
T-Rex
Moderator
Moderator
Posts: 1249
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Post by T-Rex »

Well, It seems that you have Debug build of your wxWidgets binaries. That's why your executable size is ~22Mb. You should use Release build (which is also far more faster).

150Kb under Linux.... it seems that you compiled wxWidgets with --enable-shared flag. In this case your application should not work on other Linux machines if the do not have wxWidgets runtime installed. (E.g. to I had to download binary version of wxWidgets to make MinGWStudio work under Ubuntu Linux because it seems that MinGWStudio was built with shared version of libs)
kornerr
Experienced Solver
Experienced Solver
Posts: 66
Joined: Wed Oct 12, 2005 2:43 pm
Location: Russia
Contact:

Post by kornerr »

I've done "strip -g --strip-unneeded" onto my exe, and now it's of 2.2M. It works without wx installed, but needs mingwm10.dll (14K).
Is this a normal size of a static app? Or it should be smaller?

Thanks.
Open Source all the way, baby ;)
OpenGameStudio
Image
geralds
I live to help wx-kind
I live to help wx-kind
Posts: 186
Joined: Tue Nov 01, 2005 9:22 am
Contact:

Post by geralds »

2.2 MB sounds like a fair size to me.
User avatar
T-Rex
Moderator
Moderator
Posts: 1249
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Post by T-Rex »

Unfortunately it seems that you can't make it smaller using MinGW. But you still can use MSVC++ 2005 Express which is free. It makes lighter binaries (after packing 400-900 KB)
Ksmith22
I live to help wx-kind
I live to help wx-kind
Posts: 199
Joined: Mon Nov 21, 2005 4:34 pm

Post by Ksmith22 »

Yeah, that sounds about right. Though Release version should be about half the size of Debug in my experience (though this is with MSVC++). I believe there are also other programs out there that will shrink the size of your executable some more. I've seen a few topics around these boards about that I think.
kornerr
Experienced Solver
Experienced Solver
Posts: 66
Joined: Wed Oct 12, 2005 2:43 pm
Location: Russia
Contact:

Post by kornerr »

Thanks.

When I compress binary (by bzip2) it weights ~700K. So it even fits on a floppy)
Open Source all the way, baby ;)
OpenGameStudio
Image
leio
Can't get richer than this
Can't get richer than this
Posts: 802
Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn
Contact:

Post by leio »

I get about 2.2MB binaries out of MSVC6 after the std::iostreams are used by default in wx.
This packed with UPX is below 800KB. Used to get 550KB with MSVC6 - haven't tried mingw32 and packing the resulting binaries of it with UPX.

In other words, check out UPX if you already haven't
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD

Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/
kornerr
Experienced Solver
Experienced Solver
Posts: 66
Joined: Wed Oct 12, 2005 2:43 pm
Location: Russia
Contact:

Post by kornerr »

leio,
WOW! UPX is really great! It compressed my binary to 646K!!! Even better than bzip2!
Thank you very much!

PS: If you know of other such useful apps, Please Let Me Know.
Open Source all the way, baby ;)
OpenGameStudio
Image
Post Reply