Results 1 to 7 of 7

Thread: use libs under qt4

  1. #1
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default use libs under qt4

    Hi everybody,

    NOW:
    OS:WINXP PRO
    QT: 4.1.1
    Compiler: MINGW 4.1

    Bevor:
    OS: WINXP
    QT: 3.3.4
    Compiler: .NET

    I have programed in the past a small program that use a dll, h, lib (original from device)
    I have not compiled this, its original delivered.

    The program works fine on qt3 but not in qt4. If i include this header file i get erros:
    Qt Code:
    1. #ifdef __cplusplus
    2. extern "C" {
    3. #endif
    4.  
    5. #define FUNCTION __declspec(dllimport)
    6.  
    7. FUNCTION long __stdcall OpenDevice(long CardAddress);
    8. FUNCTION __stdcall CloseDevice();
    9. FUNCTION long __stdcall ReadAnalogChannel(long Channel);
    10. FUNCTION __stdcall ReadAllAnalog(long *Data1, long *Data2);
    11. FUNCTION __stdcall OutputAnalogChannel(long Channel, long Data);
    12. FUNCTION __stdcall OutputAllAnalog(long Data1, long Data2);
    13. FUNCTION __stdcall ClearAnalogChannel(long Channel);
    14. FUNCTION __stdcall ClearAllAnalog();
    15. FUNCTION __stdcall SetAnalogChannel(long Channel);
    16. FUNCTION __stdcall SetAllAnalog();
    17. FUNCTION __stdcall WriteAllDigital(long Data);
    18. FUNCTION __stdcall ClearDigitalChannel(long Channel);
    19. FUNCTION __stdcall ClearAllDigital();
    20. FUNCTION __stdcall SetDigitalChannel(long Channel);
    21. FUNCTION __stdcall SetAllDigital();
    22. FUNCTION bool __stdcall ReadDigitalChannel(long Channel);
    23. FUNCTION long __stdcall ReadAllDigital();
    24. FUNCTION long __stdcall ReadCounter(long CounterNr);
    25. FUNCTION __stdcall ResetCounter(long CounterNr);
    26. FUNCTION __stdcall SetCounterDebounceTime(long CounterNr, long DebounceTime);
    27.  
    28. #ifdef __cplusplus
    29. }
    30. #endif
    To copy to clipboard, switch view to plain text mode 

    error:
    Qt Code:
    1. In file included from test2.cpp:1:
    2. test2.h:22:7: warning: no newline at end of file
    3. In file included from test2.cpp:2:
    4. K8055d.h:8: error: expected constructor, destructor, or type conversion before '
    5. ;' token
    6. K8055d.h:10: error: expected constructor, destructor, or type conversion before
    7. ';' token
    8. K8055d.h:11: error: expected constructor, destructor, or type conversion before
    9. ';' token
    10. K8055d.h:12: error: expected constructor, destructor, or type conversion before
    11. ';' token
    12. K8055d.h:13: error: expected constructor, destructor, or type conversion before
    13. ';' token
    14. K8055d.h:14: error: expected constructor, destructor, or type conversion before
    15. ';' token
    16. K8055d.h:15: error: expected constructor, destructor, or type conversion before
    17. ';' token
    18. K8055d.h:16: error: expected constructor, destructor, or type conversion before
    19. ';' token
    20. K8055d.h:17: error: expected constructor, destructor, or type conversion before
    21. ';' token
    22. K8055d.h:18: error: expected constructor, destructor, or type conversion before
    23. ';' token
    24. K8055d.h:19: error: expected constructor, destructor, or type conversion before
    25. ';' token
    26. K8055d.h:20: error: expected constructor, destructor, or type conversion before
    27. ';' token
    28. K8055d.h:21: error: expected constructor, destructor, or type conversion before
    29. ';' token
    30. K8055d.h:25: error: expected constructor, destructor, or type conversion before
    31. ';' token
    32. K8055d.h:26: error: expected constructor, destructor, or type conversion before
    33. ';' token
    34. test2.cpp:26:2: warning: no newline at end of file
    35. mingw32-make[1]: *** [tmp\obj\release_shared\test2.o] Error 1
    36. mingw32-make[1]: Leaving directory `D:/apps/Qt/4.1.1/test2'
    37. mingw32-make: *** [release] Error 2
    To copy to clipboard, switch view to plain text mode 
    I have included the libs like in qt3 .pro file:
    Qt Code:
    1. win32:LIBS += K8055D_C.lib
    To copy to clipboard, switch view to plain text mode 

    So i use the same filosofie to program it in qt4, but why qt4 have a problem with this header file?
    Think DigitalGasoline

  2. #2
    Join Date
    Jan 2006
    Posts
    22
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: use libs under qt4

    Quote Originally Posted by raphaelf
    Hi everybody,
    NOW:
    Compiler: MINGW 4.1

    Bevor:
    Compiler: .NET
    IMHO this is not a problem from the differences between Qt3 and Qt4, but rather with the different compilers. Obviously MINGW does not understand the code in the header file.

    Just a shot in the dark: Try removing the stdcall stuff.

  3. #3
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: use libs under qt4

    Hi,
    You think:
    Qt Code:
    1. FUNCTION CloseDevice();
    To copy to clipboard, switch view to plain text mode 
    instead of:
    Qt Code:
    1. FUNCTION __stdcall CloseDevice();
    To copy to clipboard, switch view to plain text mode 

    It not works

    But __stdcall is not supported by mingw i think, because if i edit the header file to:
    Qt Code:
    1. #ifdef __cplusplus
    2. extern "C" {
    3. #endif
    4.  
    5. #define FUNCTION __declspec(dllimport)
    6.  
    7. FUNCTION long __stdcall OpenDevice(long CardAddress);
    8.  
    9.  
    10. #ifdef __cplusplus
    11. }
    12. #endif
    To copy to clipboard, switch view to plain text mode 
    I can use this function "OpenDevice" without problem.

    What should i do?
    Last edited by raphaelf; 26th February 2006 at 16:19.
    Think DigitalGasoline

  4. #4
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: use libs under qt4

    have nobody a idea how to use my header file? I have there a problem with stdcall i think
    Think DigitalGasoline

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: use libs under qt4

    Qt Code:
    1. FUNCTION __stdcall CloseDevice();
    2. FUNCTION __stdcall ReadAllAnalog(long *Data1, long *Data2);
    3. FUNCTION __stdcall OutputAnalogChannel(long Channel, long Data);
    4. FUNCTION __stdcall OutputAllAnalog(long Data1, long Data2);
    5. FUNCTION __stdcall ClearAnalogChannel(long Channel);
    6. FUNCTION __stdcall ClearAllAnalog();
    7. FUNCTION __stdcall SetAnalogChannel(long Channel);
    8. FUNCTION __stdcall SetAllAnalog();
    9. FUNCTION __stdcall WriteAllDigital(long Data);
    10. FUNCTION __stdcall ClearDigitalChannel(long Channel);
    11. FUNCTION __stdcall ClearAllDigital();
    12. FUNCTION __stdcall SetDigitalChannel(long Channel);
    13. FUNCTION __stdcall SetAllDigital();
    14. FUNCTION __stdcall ResetCounter(long CounterNr);
    15. FUNCTION __stdcall SetCounterDebounceTime(long CounterNr, long DebounceTime;
    To copy to clipboard, switch view to plain text mode 
    All of those functions are missing the return value type. Did you try to add "void" between "FUNCTION" and "__stdcall"?

  6. #6
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: use libs under qt4

    Hi Jacek!!

    Thank you very much it works..How did you find that out?
    Think DigitalGasoline

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: use libs under qt4

    Quote Originally Posted by raphaelf
    How did you find that out?
    You wrote that "FUNCTION long __stdcall OpenDevice(long CardAddress);" works, so I focused on the differences between this and other declarations.

Similar Threads

  1. Project file LIBS debug/release
    By bunjee in forum Qt Programming
    Replies: 5
    Last Post: 27th July 2015, 05:42
  2. Linking against different Libs
    By AlphaWolf in forum Qt Programming
    Replies: 3
    Last Post: 10th February 2009, 15:25
  3. problem with order of libs during linking
    By minimax in forum Qt Programming
    Replies: 2
    Last Post: 8th January 2008, 10:32
  4. makefile troubles
    By Walsi in forum Qt Programming
    Replies: 6
    Last Post: 12th April 2007, 15:12
  5. Bad relink libs on QT4 Mac OSX (install_name_tool)
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 7th April 2007, 09:01

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.