How to create a shared library containing a wxWidgets GUI? 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
david_mtl
Earned a small fee
Earned a small fee
Posts: 20
Joined: Fri Jan 10, 2020 4:13 pm

How to create a shared library containing a wxWidgets GUI?

Post by david_mtl » Wed Jan 15, 2020 6:18 pm

Greetings everyone,

I'm currently evaluating wxWidgets to migrate our library of tools written in MFC into a cross-platform framework (Windows/Mac/Linux).

Our tools make heavy use of custom DLLs containing MFC dialogs and I want to keep the same strategy.

So far, I managed to create a wxWidgets projects in code::block that works on windows and linux using different build target. I also created another project to build a shared library. This shared library exposes a single function that adds two number together. The goal was to prove that I could create a cross-platform shared library in code::block; the results are very promising, under Windows it generates a DLL and under linux a .so, so far so good!

My next step is to create a shared library in code::block that uses wxWidgets to display a custom dialog, and use that dialog inside an host app also using wxWidgets. The step after that is to make this shared library cross-platform.

Here's the thing I'm struggling with:

How to create a project in code::block to build a shared library that uses wxWidgets? I took a look at the dll Sample in wxWidgets but it's setup to run inside a separate event loop and I don't believe this is what I need. I was expecting something more straight-forward, maybe I'm wrong though.

Note that:
- This library of tools will be maintained entirely by me and used exclusively in-house. I am fine with making sure the shared libraries I'm creating are compiled with the same version of wxWidgets than the apps that use them. I don't mind recompiling and redeploying all tools whenever necessary.
- Our tool might be using multiple custom shared libraries.
- I would prefer to not link wxWidgets statically with my dlls. (edit:actually not sure if that is important, I wanted to limit the size of the dlls.)

I've google it and searched the wiki and forum but I find it difficult to find up-to-date information. Also the keyword "shared library" returns mostly discussion on how to build wxWidgets.

So, if anyone have any pointers, I am all ears!

PS: I need to say a huge thank you to Ken_SF (not sure how to tag him, if you see him, high five him for me) for the installation instructions found in this thread: viewtopic.php?f=19&t=46125. As a newbe, it helped me tremendously setting up everything correctly. This info should be plastered all over the Wiki.

Thanks!

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

Re: How to create a shared library containing a wxWidgets GUI?

Post by ONEEYEMAN » Wed Jan 15, 2020 10:24 pm

Hi,
It looks like you can use MSVC. The software will be used in-house only (non-commercial) and will use dynamic linking.
If you can - I can refer you to my project which does exactly this:

1. Main app linked dynamically to wxWidgets.
2. Library that contains couple of dialogs which uses wxWidgets.

This project is developed and tested on all 3 major platforms (Windows/Linux/Mac).

MSVC/Anjuta/Xcode is being used on them.

MSVC Community is free for use.
Anjuta is also free
And so is Xcode.

I will refer you to the instructions on how to set up the Xcode project as well.

Let me know.

Thank you.

david_mtl
Earned a small fee
Earned a small fee
Posts: 20
Joined: Fri Jan 10, 2020 4:13 pm

Re: How to create a shared library containing a wxWidgets GUI?

Post by david_mtl » Thu Jan 16, 2020 12:53 pm

Hi ONEEYEMAN, thanks for the offer, I would love to see your project setup.

I have a few more questions if you don't mind:

Why have you decided to use 3 different IDE instead of a cross-platform one like code block or codelite? Personnaly, I find the idea of a single IDE to compile on all 3 platforms quite enticing, maybe I'm missing something.

Do you use the monolith shared librairy for wxWidgets?

Do your custom shared libraries run in their own thread with their own instance of wxWidgets like in the dll example that comes with wxWidgets?

Again, thanks a lot.

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

Re: How to create a shared library containing a wxWidgets GUI?

Post by ONEEYEMAN » Thu Jan 16, 2020 1:38 pm

Hi,
david_mtl wrote:
Thu Jan 16, 2020 12:53 pm
Hi ONEEYEMAN, thanks for the offer, I would love to see your project setup.

I have a few more questions if you don't mind:

Why have you decided to use 3 different IDE instead of a cross-platform one like code block or codelite? Personnaly, I find the idea of a single IDE to compile on all 3 platforms quite enticing, maybe I'm missing something.
Because wxWidgets is native cross-platform library. So I wanted to use native IDE on all 3 platforms.
Besides at that time, I was only familiar with MSVC and wanted to get acquainted with other 2.
david_mtl wrote:
Thu Jan 16, 2020 12:53 pm
Do you use the monolith shared librairy for wxWidgets?
No monolithic build on all 3 platforms. I do set c++11 though.
david_mtl wrote:
Thu Jan 16, 2020 12:53 pm
Do your custom shared libraries run in their own thread with their own instance of wxWidgets like in the dll example that comes with wxWidgets?
No, they are running in the same thread.
david_mtl wrote:
Thu Jan 16, 2020 12:53 pm
Again, thanks a lot.
NP. That's why we are here. ;-)

Thank you.

david_mtl
Earned a small fee
Earned a small fee
Posts: 20
Joined: Fri Jan 10, 2020 4:13 pm

Re: How to create a shared library containing a wxWidgets GUI?

Post by david_mtl » Thu Jan 16, 2020 2:03 pm

Sounds exactly like what I am trying to do. Any chance I can look at your project?

Thanks,

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

Re: How to create a shared library containing a wxWidgets GUI?

Post by T-Rex » Thu Jan 16, 2020 2:07 pm

2david_mtl
You could try to use this repo as a reference.
It utilizes CMake for generating projects for each platform. You can use the CMake generator for the IDE of your choice.

david_mtl
Earned a small fee
Earned a small fee
Posts: 20
Joined: Fri Jan 10, 2020 4:13 pm

Re: How to create a shared library containing a wxWidgets GUI?

Post by david_mtl » Thu Jan 16, 2020 2:37 pm

Looks very interesting, thanks a lot!

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

Re: How to create a shared library containing a wxWidgets GUI?

Post by ONEEYEMAN » Thu Jan 16, 2020 3:29 pm

Sent by PM (it is still work in progress).
Just look at the dialogs folder there..

Thank you.

Post Reply