Results 1 to 4 of 4

Thread: Trouble linking static library

  1. #1
    Join Date
    May 2009
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Trouble linking static library

    I've been given a DLL ( and .h file) that is used to read a certain type of files.
    These are the instructions provided in the help file:

    Qt Code:
    1. DataIO is supplied as a DLL. Incorporating this into a C++ program requires three files:
    2.  
    3. DataIO.DLL This is the dynamic link library file supplied with the SDK.
    4. This should be located in a path visible to your program (i,e, in the same directory as your
    5. .EXE file or in the WINDOWS\SYSTEM32 directory of your computer.
    6.  
    7. DataIO.LIB This must be created from DataIO.DLL using the utility supplied with your compiler
    8. (IMPLIB.EXE in the case of Borland). DataIO.LIB must be linked with your program.
    9.  
    10. DataIO.H This is the header file containing the definitions of all the procedures, structures
    11. etc. used in DataIO. This must be included in any code file using the SDK. Note the
    12. TOPDIO definition described below.
    13.  
    14.  
    15.  
    16. This simple code fragment shows how this is done:
    17.  
    18.  
    19. #include <stdio.h> // for I/O routines in this fragment
    20. #include <windows.h> // This is required (may be implicit in other
    21. // headers such as vcl.h)
    22. #define TOPDIO // This statement MUST precede the DataIO.h include
    23. // in ONLY ONE file of your program
    24. #include "Dqp_DataIo.h" // Include the DataIO definitions
    25.  
    26.  
    27. int main(int argc, char* argv[])
    28. {
    29. //...not important
    30. }
    To copy to clipboard, switch view to plain text mode 

    After much hair-pulling, googling and IRC...ing I managed to figure out how to create the .lib file: first create a .ref file using Borland's impdef.exe tool, then create the .lib using MinGW's dlltool.exe

    So now I have DataIO.lib added into my .pro file using: LIBS += DataIO.lib
    but when I follow the instructions above and include the Dqp_DataIo.h file I get TONS of compiler errors... ranging from multiple [ 'WORD' does not name a type ] or [ 'DWORD' does not name a type ] errors spawning from a struct with members of (apparently) type WORD (and DWORD) without a typedef... to [ ISO C++ forbids declaration of 'blah' with no type ]


    The header file is huge (~1200 lines) and I know I shouldn't be messing around with it so is there any way to alleviate these errors? Maybe changing some compiler options??

    Any help would be greatly appreciated!!

  2. #2
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Trouble linking static library

    thats strange cuz i think those ARE defined in windows.h .. can you share the exact errors, just like they appear on your output

  3. #3
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Trouble linking static library

    Are you sure this is a static lib? It says "DataIO is supplied as a DLL".
    I'm a rebel in the S.D.G.

  4. #4
    Join Date
    May 2009
    Posts
    61
    Thanks
    5
    Thanked 6 Times in 6 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Trouble linking static library

    On windows, when you create a dll, then it also has a corresponding .lib file. The lib file has to be linked against the app, the dll has to be in the running path.

    But I do not understand why it has to be generated from the .dll file...? They justcould have add them to the zip?

Similar Threads

  1. Extending a plugin in a static library
    By ultim8 in forum Qt Programming
    Replies: 5
    Last Post: 25th March 2010, 15:10
  2. Replies: 16
    Last Post: 23rd May 2008, 10:12
  3. Replies: 1
    Last Post: 5th March 2007, 20:50
  4. I got two problems when I used static compiled library of QT4
    By qintm in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2006, 08:52
  5. Replies: 4
    Last Post: 20th February 2006, 09:11

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.