Distrubuting wxWidgets Application in Windows and Linux Topic is solved

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.
Post Reply
Priya
Knows some wx things
Knows some wx things
Posts: 43
Joined: Fri Apr 07, 2017 8:38 am

Distrubuting wxWidgets Application in Windows and Linux

Post by Priya »

Hi,

I have developed a small application using wxWidgets statically linked. Tested the application in Windows 7 and Linux Ubuntu 16.10 where i have installed the wxWidgets.

If i want to share/distrubute the small application to team for usage, what need to be packed with my .exe so that it can run on any window pc and Linux pc without installing wxWidgets on users pc??.

Please help.

Regards,
Priya
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Distrubuting wxWidgets Application in Windows and Linux

Post by DavidHart »

Hi,

You've now discovered why static-linking is not usually done on Linux. A statically-linked program built on ubuntu 16.10 (presumably 64 bit) will not work on 32 bit systems, or on other distros e.g. fedora or openSUSE. It might work on other recent versions of ubuntu (17.04 was released a few days ago) and possibly on debian.
However even on ubuntu 16.10 it isn't guaranteed to work, as a executable program cannot rely on all its dependencies being present on every end-user's installation.

What you should do is to link dynamically to wx and any other dependencies. You should then package your program in the correct way for that distro i.e. as a .deb for debianish distros like ubuntu. Fedora and openSUSE use rpm. Both of these let you say what dependencies your program has e.g. that distro's wxWidgets library packages. When the end-user installs using the distro's package manager, it sees those dependencies and offers to install them; it refuses to install the program otherwise.

Regards,

David
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Distrubuting wxWidgets Application in Windows and Linux

Post by PB »

As for Windows: It depends on the compiler and how you built wxWidgets and your application.

As far as I know:
MinGW32: requires the CRT DLLs
TDM-GCC-64: does not require CRT DLLs
MSVC: requires the CRT DLL by default but it can be linked statically if you built wxWidgets that way.

If you are not sure which DLLs your application needs (as they depend on the compiler and its version) you can use Dependency Walker or just run the application on a clean VM/PC .
Priya
Knows some wx things
Knows some wx things
Posts: 43
Joined: Fri Apr 07, 2017 8:38 am

Re: Distrubuting wxWidgets Application in Windows and Linux

Post by Priya »

Hi,
Thank you DavidHart and PB
I actually used statically linking to make my application light weight. Now my small application .exe itself come around(8.94 MB).
If i do by dynamically linking will .exe size increase(both in Linux and Windows)??
I am planing to share the app as folder not by any installer.

For Windows, i downloaded the wxWidgets 3.1.0 and build thru visual studio 15 IDE.
So i need to give visual studio redistribution pack right?? . For wxWidgets what are the lib i need to provide to the user?
Or if i do with dynamically linking how i can proceed?

I have developed in windows 7 64 bit. Tried the app in windows 7 32 bit(wxWidgets installed in this pc). It didnt work.
I changed the configuration and build for 32 bit(x86 with wxWidgets). Now the app is working in windows 7 32 bit PC. Is that correct??

Please let me know what are the steps i should follow to distrubute my app.

Regards,
Priya
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Distrubuting wxWidgets Application in Windows and Linux

Post by DavidHart »

If i do by dynamically linking will .exe size increase(both in Linux and Windows)??
On Linux at least, it will decrease. Instead of containing the wx libs on which it depends, it will link to the distro ones that will already be installed.
I am planing to share the app as folder not by any installer.
That is not how Linux does things, because of all the dependencies. It won't work as you suggest because wxWidgets itself has dependencies, and those won't be statically linked to your program. Once installed, your program will look for those secondary dependencies outside the folder. You can't be sure they will exist.

There is a move towards trying to make standalone installable programs of the sort you want. See e.g. snaps. However they are new. I've no experience with them, but I would guess you will find it harder than doing it the standard way of creating a deb.
And you would still need to create one for each target distro/arch/version.
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Distrubuting wxWidgets Application in Windows and Linux

Post by doublemax »

I can only speak for Windows:

First you should link the wxWidgets libraries statically.
If you want your exe to work under 32bit Windows versions, should must create a 32bit executable of your application. If your application would benefit from a 64bit version, you can have both exes in the installer and install the correct one dynamically (see installer section below).

For the CRTs you have two options:
- use dynamic linking, which is the default. In that case you have to ship the VC redistributable package with your exe and install it automatically during the install process (see installer section below)

- link them statically, too. Then you have no external dependencies and your exe should work everywhere. This is what i always do.

If you want to use static linking for the CRTs, you have to rebuild the wxWidgets libraries and your application with the new option:

Load the VS solution file, e.g. <wxdir>/build/msw/wx_vc14.sln

Select the configuration "debug".

Select all libraries from "adv" to "xrc" in the solution explorer. Right click any of them, click "Properties". (Make sure all libs are still selected)

Switch to "Configuration Properties" -> "C / C++" -> "Code Generation"

Under "Runtime Library" change "Multithreaded-Debug DLL" to ""Multithreaded-Debug"

Rebuild the whole solution.

Then repeat the same for the "Release" configuration (of course with "Multithreaded" instead of "Multithreaded-Debug" )

Afterwards perform the same steps with your application and check if it still build and compiles.


Depending on the target audience for your application, it's recommended to wrap your application in an installer that guides the user through the installation process (even if it has to copy only one file, the exe) and most importantly also provides an uninstaller. Also, if you need to ship the VC redistributable package with your application because you use dynamic linking, you can add this into the installer and execute it automatically during the installation.

I personally use "Inno Setup" http://www.jrsoftware.org/isinfo.php

Another option would be NSIS: http://nsis.sourceforge.net/Main_Page
Use the source, Luke!
Priya
Knows some wx things
Knows some wx things
Posts: 43
Joined: Fri Apr 07, 2017 8:38 am

Re: Distrubuting wxWidgets Application in Windows and Linux

Post by Priya »

Hi,
Thank you doublemax and DavidHart.

I Am able to share my exe(Statically linked) to windows and Linux. Tested Linux in 16.10 only but without installing wxWidgets.

One more doubt. Am using wxXmlDocument. Small file are getting loaded properly. But above 500KB- 30 MB file are not getting loaded .

Am not able to figure out how to solve this issue.

Please guide me to solve this issue.

Regards,
Priya
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Distrubuting wxWidgets Application in Windows and Linux

Post by doublemax »

Am using wxXmlDocument. Small file are getting loaded properly. But above 500KB- 30 MB file are not getting loaded .
That's a different issue, if my following answer doesn't help, please open a new thread for this.

But unless your system runs out of memory, i don't think the size of the file shouldn't make any difference. Check the character encoding of the file and maybe use an online XML validators to check the structure of the file.
Use the source, Luke!
Post Reply