Hello all,
I am working with QT Creator 1.2.1 on Windows Vista 32bit and I would like to create a library file fora hiddevice class. I have the project set up as below... Basically I created these cpp/h files for using an hiddevice with QT and the files work fine when included in a project and utilized. Now I thought that I should put them into a ".a" file or a ".dll" file and just reference the library in the pro file of a project, negating the need to "#include <hiddevice.h>" in my project. When I build the Library project, it completes fine. When I load the libary in the other project to use, I get issues with "DWORD not naming a type" and others like it. Obviously the library was created incorrectly or my linking process is skewed. If anyone has some light they can shed on library creation with QTCreator or perhaps a better way to go about implementing what I am after, please advise!!
Thanks as always,
AlphaWolfXV

hiddevice.pro
Qt Code:
  1. #-------------------------------------------------
  2. #
  3. # Project created by QtCreator 2010-02-01T13:39:43
  4. #
  5. #-------------------------------------------------
  6.  
  7. QT -= gui
  8.  
  9. TARGET = hiddevice
  10. TEMPLATE = lib
  11.  
  12. DEFINES += HIDDEVICE_LIBRARY
  13.  
  14. SOURCES += hiddevice.cpp
  15.  
  16. HEADERS += hiddevice.h\
  17. hiddevice_global.h
  18. LIBS += -L"../../mingw/lib" \
  19. -lhid \
  20. -L"../../mingw/lib" \
  21. -lsetupapi
  22. QMAKE_LFLAGS += -Xlinker -Bstatic
To copy to clipboard, switch view to plain text mode 


hiddevice_global.h
Qt Code:
  1. #ifndef HIDDEVICE_GLOBAL_H
  2. #define HIDDEVICE_GLOBAL_H
  3.  
  4. #include <QtCore/qglobal.h>
  5.  
  6. #if defined(HIDDEVICE_LIBRARY)
  7. # define HIDDEVICESHARED_EXPORT Q_DECL_EXPORT
  8. #else
  9. # define HIDDEVICESHARED_EXPORT Q_DECL_IMPORT
  10. #endif
  11.  
  12. #endif // HIDDEVICE_GLOBAL_H
To copy to clipboard, switch view to plain text mode 

hiddevice.h
Qt Code:
  1. #ifndef HIDDEVICE_H
  2. #define HIDDEVICE_H
  3.  
  4. #include "hiddevice_global.h"
  5. #include <qt_windows.h>
  6. #include <dbt.h>
  7. #include <stdlib.h>
  8. extern "C" {
  9. #include "../../mingw/include/ddk/hidsdi.h"
  10. #include "../../mingw/include/setupapi.h"
  11. }
  12.  
  13. #include <qDebug>
  14. //#include <QThread>
  15. #include <QMutex>
  16. //if new version files for QT/MINGW need to remove any dependancy on #if _WIN32_WINNT >= 0x0500 to fix
  17. //compile errors, should be in mingw/include/winuser.h, dbt.h, until we can figure out how to get it to build
  18. //correctly~!
  19.  
  20. //Return Codes
  21. #define HID_DEVICE_SUCCESS 0x00
  22. #define HID_DEVICE_NOT_FOUND 0X01
  23. #define HID_DEVICE_NOT_OPENED 0x02
  24. #define HID_DEVICE_ALREADY_OPENED 0x03
  25. #define HID_DEVICE_TRANSFER_TIMEOUT 0x04
  26. #define HID_DEVICE_TRANSFER_FAILED 0x05
  27. #define HID_DEVICE_CANNOT_GET_HID_INFO 0x06
  28. #define HID_DEVICE_HANDLE_ERROR 0x07
  29. #define HID_DEVICE_INVALID_BUFFER_SIZE 0x08
  30. #define HID_DEVICE_SYSTEM_CODE 0x09
  31. #define HID_DEVICE_UNKNOWN_ERROR 0xFF
  32.  
  33. //Max number of USB DEVICES allowed
  34. #define MAX_USB_DEVICES 64
  35.  
  36. //Max Report Requests at a time
  37. #define MAX_REPORT_REQUEST_XP 512
  38. #define MAX_REPORT_REQUEST_2K 200
  39.  
  40. #define DEFAULT_REPORT_INPUT_BUFFERS 0
  41. #define MAX_SERIAL_STRING_LENGTH 256
  42.  
  43. class HIDDEVICESHARED_EXPORT HIDDevice {
  44. public:
  45. HIDDevice();
  46. void resetDeviceData();
  47. DWORD getConnectedDeviceNum(WORD vid, WORD pid);
  48. BYTE getSerialString(DWORD deviceIndex, WORD vid, WORD pid, LPSTR serialString, DWORD serialStringLength);
  49. BYTE close();
  50. bool isOpened();
  51. BYTE Open(DWORD deviceIndex, WORD vid, WORD pid, WORD numInputBuffers);
  52. bool getHidDevicePath(DWORD index, char* devicePath);
  53. HANDLE openDeviceByVidPid(char* devicePath, WORD vid, WORD pid);
  54.  
  55. BYTE setReport_Feature(BYTE* buffer, DWORD bufferSize);
  56. BYTE getReport_Feature(BYTE* buffer, DWORD bufferSize);
  57. BYTE setReport_Interrupt(BYTE* buffer, DWORD bufferSize);
  58. BYTE getReport_Interrupt(BYTE* buffer, DWORD bufferSize, WORD numReports, DWORD* bytesReturned);
  59. // BYTE setReport_Control(BYTE* buffer, DWORD bufferSize); //not imp in qt/mingw...
  60. // BYTE getReport_Control(BYTE* buffer, DWORD bufferSize); //not imp in qt/mingw...
  61. WORD getInputReportBufferLength();
  62. WORD getOutputReportBufferLength();
  63. WORD getFeatureReportBufferLength();
  64. WORD getMaxReportRequest();
  65. bool flushBuffers();
  66. void setTimeouts(UINT getReportTimeout, UINT setReportTimeout);
  67. void getTimeouts(UINT* getReportTimeout, UINT* setReportTimeout);
  68.  
  69. virtual ~HIDDevice();
  70. protected:
  71. QMutex* mutex;
  72. private:
  73.  
  74. HANDLE m_Handle;
  75. bool m_DeviceOpened;
  76.  
  77. UINT m_GetReportTimeout;
  78. UINT m_SetReportTimeout;
  79.  
  80. WORD m_InputReportBufferLength;
  81. WORD m_OutputReportBufferLength;
  82. WORD m_FeatureReportBufferLength;
  83.  
  84. WORD m_MaxReportRequest;
  85.  
  86. };
  87. #define LOCK_MUTEX() mutex->lock();
  88. #define UNLOCK_MUTEX() mutex->unlock();
  89.  
  90. #endif // HIDDEVICE_H
To copy to clipboard, switch view to plain text mode 


pro in linked application:
Qt Code:
  1. TARGET = WEM_ProgData
  2. TEMPLATE = app
  3. HEADERS += wemprogdata.h \
  4. proginterface.h
  5. SOURCES += wemprogdata.cpp \
  6. main.cpp \
  7. proginterface.cpp
  8. INCLUDEPATH += e:/data/workingsvn/swSrcLib \
  9. c:/data/swSrcLib
  10. LIBS += -L"../../mingw/lib" \
  11. -lhid \
  12. -L"../../mingw/lib" \
  13. -lsetupapi \
  14. -L"../swSrcLib" \
  15. -lhiddevice
To copy to clipboard, switch view to plain text mode 
If the implementation file is needed, please advise and I can upload!