Please don't link to code pasted on 3rd party sites. It tends to disappear over time and the forum thread becomes practically useful. Instead use the attachment feature of the forum.
Please don't link to code pasted on 3rd party sites. It tends to disappear over time and the forum thread becomes practically useful. Instead use the attachment feature of the forum.
Typical errors encountered on plugins load (may or may not be relevant in your case) :
- the shared library export symbols that are not actually implemented leading to an error upon symbol resolution which on some systems prevent the shared library from being loaded at all (probably not relevant here given your code)
- the plugin and the application that attempt to load are not compiled against the same version of Qt. You should pay particular attention to the build mode (release or debug). It must be the same for the app and the plugins AFAIK.
A good way to determine what's wrong is to load the shared lib by hand using QLibrary instead of QPluginLoader and to watch the console output to see if relevant messages are displayed. Now this won't load the actual plugin class for you but it should give an explaination if loading fails.
Current Qt projects : QCodeEdit, RotiDeCode
Thank you. I've gotten the plugin to load now. Can't figure out what was wrong though, but I dead a clean project in QtCreator and now it works. Have not been able to reproduce the problem.
But now I cannot call member functions on the object. Getting bus error
What Im doing is I create a QPluginLoader object for my plugin, make sure it is loaded, get the instance using instance() and then typecast it with qobject_cast to my interface class. Cannot see what I'm doing wrong.
See attached file which is a small test case.
Things like that happen sometimes. It usually comes from the way qmake dependency handling accross subdirs (or lack thereof). When you change a header file for your interface the plugin won't be recompiled unless that file appears in the HEADERS variable of the plugin project file.
Actual console output and/or full code (including plugin) would help.
Current Qt projects : QCodeEdit, RotiDeCode
I am still stuck with this problem
Not getting bus error though, but the app unexpectedly quits.
My code is here: http://rafb.net/p/AvStNW98.html
Quitting when reaching line 22 where I call a function in the plugin.
The full console output from running the app is:
Starting /Users/niklas/code/test/PluginLoadingTest/PluginLoadingTest...
plugin loaded!
The program has unexpectedly finished.
I just now got it to work. Even though it seemed as if it was successfully loaded it was not. I checked if instance() was null and it was not, but the error string was not empty - it said the build key differed.
It differed even though I had recompiled both the plugin and the app since I updated to Qt 4.5.
I tried removing the plugin binary and it worked - solved my problem!
Wonder what I did wrong in QtCreator when trying to recompile...
Bookmarks