[Qt-interest] Making a Qt program into a dynamic library
Konrad Rosenbaum
konrad at silmor.de
Wed Dec 16 14:25:22 CET 2009
Hi,
I'll answer anyway, since more is amiss here...
The extern "C" should not matter since your loader does not access the
symbols.
On Wednesday 16 December 2009 11:50:43 Guido Seifert wrote:
> This is extremely strange. Here the very simple plugin I just tried:
>
> MyTest.cpp:
>
> #include <QString>
extern "C" is missing.
> void start()
> {
> QString str;
> }
>
> MyTest.pro:
>
> SOURCES += MyTest.cpp
>
> CONFIG += qtcore
I'm not sure what the above does - it should not be necessary.
> CONFIG -= thread
Hmm. This should neither be necessary, nor wise. Qt4 has threads compiled in
mandatorily (except one one or two embedded systems).
> CONFIG += shared
>
> TEMPLATE = lib
> MOC_DIR = ./.moc
> OBJECTS_DIR = ./.obj
ok, but the TARGET directive is missing
> Above results in libMyTest.so.1.0.0
> The test program, which loads the lib:
#include is missing
> int main(int argc, char *argv[])
> {
> void* handle = dlopen("./libMyTest.so.1.0.0", RTLD_LAZY);
> return 0;
> }
looks ok, but how is it compiled?
gcc -o m mymain.c -ldl
works fine for me
> Result: segfault
> Same happens when I comment out the QString.
No segfault here.
There was another conflict somewhere. It probably went away when you
recompiled everything. I guess you compiles against one version of Qt and
executed with another.
> As I said, having CONFIG += qtcore (or += qt) in .pro file is enough to
> ensure the crash. Clearly no global variables on my side.
As said: this should not be necessary, qmake always assumes that QtCore and
QtGui are in.
> What Qt version do you use?
Debians 4:4.5.3-4 and I just retried it with a 4.6.0 that I compiled myself.
Konrad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091216/2e400fcc/attachment.bin
More information about the Qt-interest-old
mailing list