wxGetApp() in plugins / dynamic libraries  [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.
Rick
Earned a small fee
Earned a small fee
Posts: 22
Joined: Fri Sep 02, 2016 12:26 pm

wxGetApp() in plugins / dynamic libraries

Postby Rick » Thu Apr 19, 2018 8:59 pm

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: 1756
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxGetApp() in plugins / dynamic libraries

Postby PB » Fri Apr 20, 2018 5:53 am

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-with-plugins-windowslinuxmac-sample-source-code/

Rick
Earned a small fee
Earned a small fee
Posts: 22
Joined: Fri Sep 02, 2016 12:26 pm

Re: wxGetApp() in plugins / dynamic libraries  [SOLVED]

Postby Rick » Sat Aug 11, 2018 8:07 pm

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.


Return to “C++ Development”

Who is online

Users browsing this forum: Bing [Bot] and 23 guests