wxGetApp() in plugins / dynamic libraries Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Rick
Knows some wx things
Knows some wx things
Posts: 33
Joined: Fri Sep 02, 2016 12:26 pm

wxGetApp() in plugins / dynamic libraries

Post by Rick »

I'd like to create a plugin system for my application so that I can add GUIs/features dynamically. I used this example so I have two projects: The main app and the plugin.
Is there a way to get access to wxGetApp() in the plugin? I've tried adding the wxDECLARE_APP(); macro (also including the header from the main project) but it doesn't work. When wxGetApp() is invoked I get
libPlugin.so: undefined symbol: _Z8wxGetAppv
As a side question: Is this the right approach for creating a plugin system?
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxGetApp() in plugins / dynamic libraries

Post by PB »

Speaking of plugins: I am not familiar with the example in the link you posted, but did you also check the DLL sample bundled with wxWidgets (including its readme.txt)? There is also this: https://wxwidgets.info/wxwidgets-app-wi ... urce-code/
Rick
Knows some wx things
Knows some wx things
Posts: 33
Joined: Fri Sep 02, 2016 12:26 pm

Re: wxGetApp() in plugins / dynamic libraries

Post by Rick »

I looked into this again after quite a break.

Found that some symbols were unknown to the library. Adding the flags

Code: Select all

-Wl, --export-dynamic
to the compiler flags (using Netbeans, I had to add it to the linker flags) made the main programme export the symbols so that my plugin can use them.
I can now successfully call my main programme's functions from my plugin.
Post Reply