Results 1 to 8 of 8

Thread: How to link win32 dll to project?

  1. #1
    Join Date
    Jul 2011
    Posts
    8
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default How to link win32 dll to project?

    Hi
    Im working on QT4 with Eclipse IDE. My project needs some win32 declarations (e.g. DWORD, PSP_DEVICE_INTERFACE_DETAIL_DATA) which are included in setupapi.h and setupapi.dll.
    With .h header there is no problem, but how to link setupapi.dll to project?

    I tried to set file: proj_name.pro
    Qt Code:
    1. LIBS += -LC:\Windows\System32 -lsetupapi
    To copy to clipboard, switch view to plain text mode 
    but it doesen't work.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to link win32 dll to project?

    If you are not working with cl.exe (the MS compiler) will have to use the specific compiler version setupapi.dll.
    If you are using MinGW, you should give the path to the MinGW system lib folder (and make sure you have the lib in there)
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jul 2011
    Posts
    8
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to link win32 dll to project?

    Thank You for reply.
    I'm using MinGW. I added the path "C:\MinGW\lib" as you said. There is no setupapi.dll but I can find there libsetupapi.a. Is that library similar to setupapi.dll?
    Anyway, i still can't compile my project with the same errors. Should I modify my proj_name.pro file?

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to link win32 dll to project?

    what is the error you get?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Jul 2011
    Posts
    8
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to link win32 dll to project?

    I have some structures, used for detecting USB Devices (but its not the point):
    Qt Code:
    1. class USBdevices {
    2. DWORD propertyBufferSize = 0;
    3. char *propertyBuffer = NULL;
    4. SP_DEVINFO_DATA deviceInfoData;
    5.  
    6. HMODULE hHidLib;
    7. HDEVINFO deviceInfoSet;
    8. SP_INTERFACE_DEVICE_DATA deviceInterfaceData;
    9. DWORD memberIndex = 0;
    10. GUID classGuid;
    11. PSP_DEVICE_INTERFACE_DETAIL_DATA deviceInterfaceDetailData = NULL;
    12. DWORD requiredSize = 0;
    13. DWORD deviceInterfaceDetailDataSize = 0;
    14.  
    15. }
    To copy to clipboard, switch view to plain text mode 
    here are the error log:
    Qt Code:
    1. USBdebives.h:27:33: error: ISO C++ forbids initialization of member 'propertyBufferSize'
    2. USBdebives.h:27:33: error: making 'propertyBufferSize' static
    3. USBdebives.h:27:33: error: ISO C++ forbids in-class initialization of non-const static member 'propertyBufferSize'
    4. USBdebives.h:28:29: error: ISO C++ forbids initialization of member 'propertyBuffer'
    5. USBdebives.h:28:29: error: making 'propertyBuffer' static
    To copy to clipboard, switch view to plain text mode 

    If I do something like that, everythings work fine. But I don't wanna heve variables declarations in constructor or in class method.

    Qt Code:
    1. USBdevices::USBdevices() //constructor
    2. {
    3. QLibrary("setupapi.dll").load(); // adding necessary library
    4. //and now declarations of all my variables and structs:
    5.  
    6. DWORD propertyBufferSize = 0;
    7. char *propertyBuffer = NULL;
    8. SP_DEVINFO_DATA deviceInfoData;
    9.  
    10. HMODULE hHidLib;
    11. HDEVINFO deviceInfoSet;
    12. SP_INTERFACE_DEVICE_DATA deviceInterfaceData;
    13. DWORD memberIndex = 0;
    14. GUID classGuid;
    15. PSP_DEVICE_INTERFACE_DETAIL_DATA deviceInterfaceDetailData = NULL;
    16. DWORD requiredSize = 0;
    17. DWORD deviceInterfaceDetailDataSize = 0;
    18.  
    19.  
    20.  
    21. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to link win32 dll to project?

    Your problem has nothing to do with libsetupapi, you have basic compilation errors.
    The errors also state what the problem is - you are not allowed to initialize members at the deceleration - you should initialize them in class implementation.
    You should first learn basic C++ syntax.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. The following user says thank you to high_flyer for this useful post:

    libed (22nd July 2011)

  8. #7
    Join Date
    Jul 2011
    Posts
    8
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to link win32 dll to project?

    sorry. thats the case when you learn java before C++;

  9. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to link win32 dll to project?

    There are Qt java bindings...
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. How to link to .o object file in a QT project
    By dexterkd in forum Qt Programming
    Replies: 3
    Last Post: 13th October 2010, 15:14
  2. Replies: 11
    Last Post: 26th May 2010, 05:33
  3. How to link GLUT to Qt Project?
    By Lawand in forum Newbie
    Replies: 5
    Last Post: 20th March 2010, 20:29
  4. how to use Qt dll in Win32 project
    By Fastman in forum Qt Programming
    Replies: 8
    Last Post: 10th July 2009, 12:16
  5. compiling a qt project under win32
    By elcuco in forum Qt Programming
    Replies: 2
    Last Post: 19th January 2006, 07:43

Tags for this Thread

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.