PDA

View Full Version : Custom Plugin Trouble



stevey
2nd November 2009, 04:07
Hi,

I'm trying to create a custom plugin using the QtPlugin framework.
I have 3 projects, a main Ui app, a "core" dll containing my plugin interface and an implementation of the plugin in another dll.

I'm getting the following compile errors in Qt Creator:


Starting: C:/Qt/2009.03/mingw/bin/mingw32-make.exe -w
mingw32-make: Entering directory `D:/Development/QtTests/TestPlugin1'
C:/Qt/2009.03/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `D:/Development/QtTests/TestPlugin1'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -shared -Wl,--out-implib,debug\libTestPlugin1.a -o debug\TestPlugin1.dll debug/TestPlugin1.o debug/moc_TestPlugin1.o -L"c:\Qt\2009.03\qt\lib" -L../TestAppCore/debug -lTestAppCore -lQtXmld4 -lQtCored4
mingw32-make[1]: Leaving directory `D:/Development/QtTests/TestPlugin1'
mingw32-make: Leaving directory `D:/Development/QtTests/TestPlugin1'
Creating library file: debug\libTestPlugin1.a
debug/TestPlugin1.o: In function `ZN8QPointerI7QObjectEaSEPS0_':
c:/Qt/2009.03/qt/include/QtCore/../../src/corelib/kernel/qpointer.h:(.text$_ZN12CustomPluginC2Ev[CustomPlugin::CustomPlugin()]+0x7): undefined reference to `_imp___ZTV12CustomPlugin'
debug/moc_TestPlugin1.o: In function `ZThn8_N11TestPlugin1D1Ev':
D:/Development/QtTests/TestPlugin1/debug/moc_TestPlugin1.cpp:(.text$_ZN11TestPlugin1D1Ev[TestPlugin1::~TestPlugin1()]+0x54): undefined reference to `_imp___ZN12CustomPluginD2Ev'
D:/Development/QtTests/TestPlugin1/debug/moc_TestPlugin1.cpp:(.text$_ZN11TestPlugin1D0Ev[TestPlugin1::~TestPlugin1()]+0x54): undefined reference to `_imp___ZN12CustomPluginD2Ev'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\TestPlugin1.dll] Error 1
mingw32-make: *** [debug] Error 2
Exited with code 2.
Error while building project TestPlugin1
When executing build step 'Make'


I think it's to do with vtables and such, but I'm not sure how to fix the problem.
I've set the following varialbes in TestPlugin1.pro:

INCLUDEPATH += ../TestAppCore
LIBS += -L../TestAppCore/debug -lTestAppCore

Can someone please point out what's probably completely obvious? ;)
I've attached the 3 projects to this thread.


Thanks,

Stephen York

wysota
3rd November 2009, 10:20
You forgot to implement the destructor for CustomPlugin.

stevey
3rd November 2009, 13:01
Actually, while tinkering I realised that.
I'm still not sure why that has to be done. Is that something to do with pure virtual interfaces, therefore the compiler tries to implicitly create a destructor which it can't because the class can't be concrete?

Steve

wysota
3rd November 2009, 13:36
I'm still not sure why that has to be done. Is that something to do with pure virtual interfaces, therefore the compiler tries to implicitly create a destructor which it can't because the class can't be concrete?

It has to do with the fact that you explicitly declared it but didn't implement it. Being pure virtual or not has little to do with this.

stevey
3rd November 2009, 14:59
Ok, I also had to inherit from QObject and specify Q_OBJECT to avoid some further conflicts.

So ... I compiled it on MacOS X but was having trouble debugging, due to the environment I have setup on the machine, so I moved it to my Windows box, but now I'm getting these errors:


Running build steps for project TestAppCore...
Configuration unchanged, skipping QMake step.
Starting: C:/Program Files/Microsoft Visual Studio .NET 2003/VC7/BIN/nmake.exe
nmake -f Makefile.Debug
cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DTESTAPPCORE_LIBRARY -DQT_DLL -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"c:\Qt\4.5.2\include\QtCore" -I"c:\Qt\4.5.2\include" -I"c:\Qt\4.5.2\include\ActiveQt" -I"debug" -I"c:\Qt\4.5.2\mkspecs\win32-msvc2008" -Fodebug\ @C:\DOCUME~1\Steve\LOCALS~1\Temp\nm1895.tmp
TestAppCore.cpp
link /LIBPATH:"c:\Qt\4.5.2\lib" /NOLOGO /DEBUG /DLL /MANIFEST /MANIFESTFILE:"debug\TestAppCore.intermediate.manifest" /OUT:debug\TestAppCore.dll @C:\DOCUME~1\Steve\LOCALS~1\Temp\nm1896.tmp

Microsoft (R) Program Maintenance Utility Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.


Microsoft (R) Program Maintenance Utility Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.

cl : Command line warning D4002 : ignoring unknown option '-Zc:-'
LINK : warning LNK4044: unrecognized option '/MANIFEST'; ignored
LINK : warning LNK4044: unrecognized option '/MANIFESTFILE:debug\TestAppCore.intermediate.manife st'; ignored
Creating library debug\TestAppCore.lib and object debug\TestAppCore.exp
mt.exe -nologo -manifest "debug\TestAppCore.intermediate.manifest" -outputresource:debug\TestAppCore.dll;2
'mt.exe' is not recognized as an internal or external command,
operable program or batch file.
NMAKE : fatal error U1077: 'mt.exe' : return code '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\BIN\nmake.exe"' : return code '0x2'
Stop.
Exited with code 2.
Error while building project TestAppCore
When executing build step 'Make'


Any idea how to get Qt Creator to find mt.exe? Is it possible to add environment variables to the build step via the .pro file? I'm surprised that mt.exe isn't in the path already after having installed Visual Studio.

Will go with a system wide env var if I have to.

Thanks,

Steve

wysota
3rd November 2009, 18:08
So... it can find cl.exe but not mt.exe? That's hardly possible unless you don't have mt.exe at all :)