[SOLVED] Create a shared library without resolving functions or a QPluginLoader interface
-
Hello there
In the past few days I played with shared and static libraries, QPlugin and QPluginLoader. Now I think it's the time to use these information in a project.
The plan: I have an application and a backend (shared library). The shared library contains signal and slots and has more than 250 methods. At the moment I link it statically - so exporting is not a problem.
Now I run into the problem of a shared library:
- Create a normal shared library and resolve more than 250 methods. Can I use signal and slots or do I have to use the extern C functions (Like the QPlugin example here: "How to create plugins":http://qt-project.org/wiki/How_to_create_a_library_with_Qt_and_use_it_in_an_application?
- Write an interface with 250 virtual functions (Overhead) and a class. Use QPluginLoader to load it at runtime
So as you can see I need the possibility of the QPluginLoader without the interface (Because the plan is to write a shared library and not an abstract plugin interface). My questions:
- Is it possible to use a shared library without an interface in combination with QPluginLoader. The solution has to work under windows (Unix-only would be very easy)
- If not, are there any other solutions ?
Thank you in advice,
Threadcore -
Hi,
Are you planning to give the means to link to your library along your library ?
-
Hi SGaist
I have the possibility to link against the (shared) library. I develop both components and deploy both in the same package.
I use CMake as a build system and under Unix is is possible to create a shared library with add_library(xyz SHARED ...) and put them in the library directory - very nice. But this does not work for windows - so that's my problem
-
Then you can use the technique described "here":http://qt-project.org/doc/qt-4.8/sharedlibrary.html
-
Ok, thank you, with the Q_DECL_EXPORT/Q_DECL_IMPORT it works like a charm under windows.