Results 1 to 8 of 8

Thread: Problems using a DLL

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2007
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    4

    Angry Re: Problems using a DLL

    Thanks fullmetalcoder for your answer. The problem is I didn´t create the Dll and I cannot modify it to include the Q_DECL_EXPORT and the Q_DECL_IMPORT. Is there any way I can still use the DLL?

  2. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 127 Times in 121 Posts

    Default Re: Problems using a DLL

    Quote Originally Posted by prosass View Post
    Thanks fullmetalcoder for your answer. The problem is I didn´t create the Dll and I cannot modify it to include the Q_DECL_EXPORT and the Q_DECL_IMPORT. Is there any way I can still use the DLL?
    Sounds weird... You mean that you grabbed a dll from some piece of software and want to use it? In this case you will need a SDK (header files and, under Window$, import library) and Qlibrary won't help you if the symbols (functions/classes) you are interested in are not exported using __declspec() (or any equivalent macro)...
    Current Qt projects : QCodeEdit, RotiDeCode

  3. #3
    Join Date
    Feb 2007
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    4

    Default Re: Problems using a DLL

    I got the DLL from a student at my university who was working on the same piece of hardware and all I got was the file .h with the functions I can use and the Dll itself.
    At the moment I don´t think I´m using QLibrary. In the .cpp file I just try to access the functions by calling them:

    Qt Code:
    1. int err = 0;
    2. err = loc_ini();
    3.  
    4. while (1) {
    5. //Sleep(1);
    6. err = loc_getposition(&loc_pos);
    7. //Sleep(500);
    8. cout << "Posicion x:" << loc_pos.x << endl;
    9. cout << "posicion y:" << loc_pos.y << endl << endl;
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

    This was enough in Code::blocks but it doesn´t work in QT/VisualStudio. Should I use something like:

    Qt Code:
    1. QLibrary Sniffer("Sniffer");
    2.  
    3. typedef void (*MyPrototype)();
    4. MyPrototype myFunction = (MyPrototype) myLib.resolve("mysymbol");
    5. if (myFunction)
    6. myFunction();
    To copy to clipboard, switch view to plain text mode 

    Should I use something like that?

  4. #4
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 127 Times in 121 Posts

    Default Re: Problems using a DLL

    Quote Originally Posted by prosass View Post
    I got the DLL from a student at my university who was working on the same piece of hardware and all I got was the file .h with the functions I can use and the Dll itself. This was enough in Code::blocks but it doesn´t work in QT/VisualStudio.
    Which files exactly do you received??? I'm particularly interested in extension like .a or .lib
    AFAIK if the compile-time linking doesn't work there are not much chances for it to work at run-time but I might be proved wrong here...
    Current Qt projects : QCodeEdit, RotiDeCode

  5. #5
    Join Date
    Feb 2007
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    4

    Default Re: Problems using a DLL

    I got the loc.h file that I wrote down in the beggining, the sniffer.dll and the following main.cpp:

    Qt Code:
    1. #include "loc.h"
    2. #include <windows.h>
    3. #include "iostream.h"
    4.  
    5. loc_position_t loc_pos;
    6.  
    7. int main(void) {
    8.  
    9. int err = 0;
    10. err = loc_ini();
    11.  
    12. while (1) {
    13. //Sleep(1);
    14. err = loc_getposition(&loc_pos);
    15. //Sleep(500);
    16. cout << "Posicion x:" << loc_pos.x << endl;
    17. cout << "posicion y:" << loc_pos.y << endl << endl;
    18. }
    19. }
    To copy to clipboard, switch view to plain text mode 

    That is all I got, do I also need a .lib file to make it work?

  6. #6
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 127 Times in 121 Posts

    Default Re: Problems using a DLL

    Quote Originally Posted by prosass View Post
    I got the loc.h file that I wrote down in the beggining, the sniffer.dll and the following main.cpp:
    That is all I got, do I also need a .lib file to make it work?
    Well, AFAIK window always require an import library to achieve linking against a dll. The file extension of these libs is .lib for MSVC and .a for gcc/mingw. If your friend did not give you such a lib you should ask for one or for the full sources...
    Current Qt projects : QCodeEdit, RotiDeCode

Similar Threads

  1. Problems with Unicode(UTF8)
    By cristiano in forum Qt Programming
    Replies: 15
    Last Post: 5th December 2006, 12:33
  2. QGLWidget Problems
    By ToddAtWSU in forum Qt Programming
    Replies: 1
    Last Post: 2nd October 2006, 22:06
  3. Problems building mysql plugin for Qt 4.1.2 on windows XP
    By Philip_Anselmo in forum Installation and Deployment
    Replies: 3
    Last Post: 17th May 2006, 15:38
  4. Canvas problems
    By Tommytrojan in forum Qt Programming
    Replies: 22
    Last Post: 9th May 2006, 16:46
  5. QT4 Plugins - problems, problems
    By NormanDunbar in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2006, 15:39

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
  •  
Qt is a trademark of The Qt Company.