HOW TO - created and use shared library (.so)
Hi all,
I've created my own shared library and tried to load it dynamically while my small test app is running. Unfortunately it's not working - the lib is not loaded!
In the .pro file for my lib:
Code:
TEMPLATE = lib
CONFIG += dll
TARGET = mylib
In the header file for my lib:
Code:
#include <Qt/qglobal.h>
#ifdef TEST_LIB
# define TEST_EXPORT Q_DECL_EXPORT
#else
# define TEST_EXPORT Q_DECL_IMPORT
#endif
class TEST_EXPORT DBConnection
{
...
};
Is there somthing else what I need to do?
Then in my test app I call the lib:
If I check it with
then I can see that the lib is not loaded.
Maybe it can't find the lib? Where I have to put my lib that its beeing loaded?
Any help would be great!!
Many thanks and best regrads
big4mil
Re: HOW TO - created and use shared library (.so)
You could place it in the same directory as the main binary.
I might be wrong here, but I think you need to wrap your methods in 'extern "C"' statements if you want to resolve symbols dynamically. And you'll need factory functions to create instances of your class.
Re: HOW TO - created and use shared library (.so)
Hi wysota,
many thanks for your response. My lib is in the same directoy as the app is. I develop under SUSE Linux 10.1.
Can you give me please one simple example on how to do this? I have never done this bevor. Would be great.
What do you mean with:
Quote:
And you'll need factory functions to create instances of your class.
Many thanks
big4mil
Re: HOW TO - created and use shared library (.so)
See the C++ dlopen mini-howto for details. QLibrary uses dlopen internally so everything there applies.
Re: HOW TO - created and use shared library (.so)
that's fine - thanks for the link...I'll check that out!!
big4mil