Results 1 to 2 of 2

Thread: MFC dll in Qt4

  1. #1
    Join Date
    Sep 2007
    Location
    Germany
    Posts
    35
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question MFC dll in Qt4

    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:

    Qt Code:
    1. QLibrary myLib("C:\\dllfolder\\MFCDLL.dll");
    2. typedef int (*MyPrototype)(bool &con);
    3. MyPrototype QLibrary myLib("C:\\dllfolder\\MFCDLL.dll");
    4. typedef int (*MyPrototype)(bool &con);
    5. MyPrototype myFunction = (MyPrototype) myLib.resolve("dllFunctionName");= (MyPrototype) myLib.resolve("dllFunctionName");
    6. bool sw;
    7. int nResult = myFunction(sw);
    To copy to clipboard, switch view to plain text mode 

    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:n_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
    Last edited by cafu; 24th September 2007 at 12:02.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: MFC dll in Qt4

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.