Setting up wxWidgets to compile with a custom project

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
sakurasanta86
In need of some credit
In need of some credit
Posts: 2
Joined: Sun Apr 22, 2018 7:34 pm

Setting up wxWidgets to compile with a custom project

Post by sakurasanta86 » Sat Apr 28, 2018 5:52 pm

Okay, I apologize for making two posts in a row, but this might just be simpler.

I want to build an application that uses wxWidgets.

However, I want to do proper version control via github, and I want portability regarding Windows 10, meaning that anyone with Windows 10 (and perhaps a few dependencies installed) should be able to clone my repository, open my main solution, compile and run it without any additional fuss.

The attempt I've made was done this way:

I created my own repository and created my solution in it. I've made wxWidgets a submodule of the repository. I've then included all of the appropriate versioned wxWidgets projects to my solution and set up the build order so they are all successfully built the first try. However, I had to mess with the _custom_build project in order to make it work (to deal with the location of setup.h), so this breaks it, since it will be reset when subomodule is cloned. This use to work for a while but it doesn't seem like a proper way of doing it.

So my question is, how do I add wxWidgets to my project as a submodule in a way that will work and will by buildable by anyone who clones the said repository?

I don't need details, I just need to know what are the general steps, what to use, where to research further, I just need something to go on.
Most of the tutorials go about how I can build it myself, but I have to set up a kind of automatic build process.

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

Re: Setting up wxWidgets to compile with a custom project

Post by ONEEYEMAN » Mon Apr 30, 2018 2:54 pm

Hi,
What is the purpose?
On Windows the "standard" way to distribute software to the end-user is to provide the msi installer novadays. Which means you should just build the library as a static modules and build you project as an executable, then create the installer for it.
On *nix it is advisable to create a software as a dynamically linked, based on the libraries provided by the distribution. So you should build it on you preferred distro and then create a deb/rpm/etc. for all other distributions of *nix in order to distribute the software.
On Mac you just submit it to the Apple Store. They can create a distributable solution for you.

There is no need to keep the whole library inside you project anywhere on any of the 3 major platforms.

Thank you.

P.S.: If you really want to do it you should consider the user who will want to compile wxWidgets in a non-standard configuration or with the compiler which is broken or the compiler that is too new and broken. Which means you will have a lot of complains about non-working software.
Be prepared!!! You have been warned!!! ;-)

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

Re: Setting up wxWidgets to compile with a custom project

Post by PB » Tue May 01, 2018 11:49 am

Sorry, I have no experience with that but what exactly is the problem? Can the automated build system be CMake?

wxWidgets now have official CMake support, see chapter Using CMake with your applications / Using a sub directory. Be aware that wxWidgets on GIT do not contain include/wx/msw/setup.h, so this may need to be addressed (e.g. telling CMake to create it by copying setup0.h).

BTW, if just manually set-up MSVC project would be good enough: POEdit, a wxWidgets application does this. Perhaps you can take a look at how it does it? https://github.com/vslavik/poedit

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

Re: Setting up wxWidgets to compile with a custom project

Post by ONEEYEMAN » Tue May 01, 2018 2:25 pm

PB,
AFAIU, (s)he does not looking for an automated build system. They are looking for a way to include wx in their git repository and build the library along with the application.

There is no problem with that - it just that on Windows astandard way of application distribution is thru the msi/installer. Therefore it will be much easier to produce the static-link binary of their software and just give it out thru the ftp/sourceforge/some other means to download. Because in *nix world it is strongly advisable to use the dynamic linking to the official distro releases.

So there is no point of keeping the wxWidgets clone inside anyone's software Git{Hub}/CVS/SourceSafe/etc. repository.

Thank you.

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

Re: Setting up wxWidgets to compile with a custom project

Post by PB » Tue May 01, 2018 3:35 pm

ONEEYEMAN wrote:PB,AFAIU, (s)he does not looking for an automated build system.
I thought he did, based on
sakurasanta86 wrote:Most of the tutorials go about how I can build it myself, but I have to set up a kind of automatic build process.
Anyway, I believe that by users the OP meant the collaborators working on the program source code, not the users of the application.

I do agree that the usual way is to provide the documentation listing the dependencies and how to obtain and build them; no C++ programmer should have an issue with that. However, the other approach may be better, for some reasons we do not know.

gunterkoenigsmann
Earned a small fee
Earned a small fee
Posts: 13
Joined: Tue May 31, 2016 11:30 am

Re: Setting up wxWidgets to compile with a custom project

Post by gunterkoenigsmann » Fri Sep 06, 2019 3:17 pm

I'm currently at the point the user who asked the original question was at: wxWidgets at compile time looks if the system provides a zlib, libpng etc. In Linux they are normally provided by the system. On Windows installing each dependency one by one by hand is possible but hard work => for this case wxWidgets provides each of its dependencies as git submodule and will use the versions of its dependencies it came with.

Providing wxWidgets as a submodule that is only compiled and statically linked if the system doesn't provide a wxWidgets would make installing my application on Linux, Windows and Mac Os simple: Just tell cmake you want to compile the source. If the only dependency (wxWidgets) is missing a statically- linkable wxWidgets is automatically compiled and linked with the application. Additionally I could package a working version of wxWidgets with my application: wx3.0 doesn't work with wxScrolled and gtk3 so I could provide a statically-linked wx3.1 with my app on Debian which wants to switch to wx3.0+Gtk3.

Post Reply