PDA

View Full Version : Creating Qt shared library for non-Qt applications



dimitar
24th November 2010, 19:42
Hello,

I am using Qt 4.6.2 on Windows.
I have a Qt DLL that is invoked from a non-Qt application. The DLL exports couple of C interface functions.
The DLL does not create QApplication and does not have any user interface elements.
The DLL is loaded dynamically and unloaded when not needed.

I noticed that every time the DLL is loaded the count of semaphore handles of the process that loads the DLL increases. When the DLL is unloaded the handles are not freed.
I searched for information on Qt cleanup, or anything that needs to be done before dynamically unloading Qt ... but did not find anything.


In the DLL, I use QCoreApplication::addLibraryPath() and the classes QImage, QByteArray and QBuffer. All the DLL does is some image transformations.

Does anyone know how can I prevent the leaked handles?

Thanks,

Dimitar

tbscope
25th November 2010, 04:33
In the DLL, I use QCoreApplication::addLibraryPath() and the classes QImage, QByteArray and QBuffer. All the DLL does is some image transformations.

It does not make sense at all to use any of the Q...Application classes inside a library. It's a library, not a program.
What do you want to achieve when you use addLibraryPath?

dimitar
25th November 2010, 11:46
I am setting the path where the Qt plugins are. If I do not do that plugins are not found/loaded.
You are right that this is a library. But is there any other way to set the library paths, and not touch Q...Application?
Can it be done with environment variable(s) (like LD_LIBRARY_PATH)?