PDA

View Full Version : MFC dll in Qt4



cafu
24th September 2007, 11:47
hi all, i am developing a small program that use a mfc dll, i am completely new in qt;

when i use this to call to a function in the dll works just fine:


QLibrary myLib("C:\\dllfolder\\MFCDLL.dll");
typedef int (*MyPrototype)(bool &con);
MyPrototype QLibrary myLib("C:\\dllfolder\\MFCDLL.dll");
typedef int (*MyPrototype)(bool &con);
MyPrototype myFunction = (MyPrototype) myLib.resolve("dllFunctionName");= (MyPrototype) myLib.resolve("dllFunctionName");
bool sw;
int nResult = myFunction(sw);

but i would like to use something like a #include directive this is possible?, i am working with visual studio 2005 i don't want to make this every time that i need a function from the dll, i have add the MFCDLL.h file to my code but still it doesn't work, any clue?

i get the follow error when i try to call the function directly from the dll icluding the MFCDLL.h file to the code and adding this line to dlltester.pro file


LIBS += C:\dllfolder\MFCDLL.dll

Error 1 error LNK2019: unresolved external symbol _dllFunctionName referenced in function "private: void __thiscall Qt_DLL_Tester::on_pushButton_2_clicked(void)" (?on_pushButton_2_clicked@Qt_DLL_Tester@@AAEXXZ) qt_dll_tester.obj

adding something: any change that i make in the .pro file doesn't look like making changes in the program.

please help.

thanks

CAFU

marcel
24th September 2007, 14:53
Well, you could create a wrapper class for the functions in the dll.
This class should also load and release the library. The loading process should be in a static function.
The class should have wrapper functions for all the needed functions in the library.

Then, you could include the header in which this class is declared in all the files that need it.

Regards