PDA

View Full Version : Trouble linking static library



russdot
15th May 2009, 00:33
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:


DataIO is supplied as a DLL. Incorporating this into a C++ program requires three files:

DataIO.DLL This is the dynamic link library file supplied with the SDK.
This should be located in a path visible to your program (i,e, in the same directory as your
.EXE file or in the WINDOWS\SYSTEM32 directory of your computer.

DataIO.LIB This must be created from DataIO.DLL using the utility supplied with your compiler
(IMPLIB.EXE in the case of Borland). DataIO.LIB must be linked with your program.

DataIO.H This is the header file containing the definitions of all the procedures, structures
etc. used in DataIO. This must be included in any code file using the SDK. Note the
TOPDIO definition described below.



This simple code fragment shows how this is done:


#include <stdio.h> // for I/O routines in this fragment
#include <windows.h> // This is required (may be implicit in other
// headers such as vcl.h)
#define TOPDIO // This statement MUST precede the DataIO.h include
// in ONLY ONE file of your program
#include "Dqp_DataIo.h" // Include the DataIO definitions


int main(int argc, char* argv[])
{
//...not important
}


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!!

talk2amulya
15th May 2009, 07:29
thats strange cuz i think those ARE defined in windows.h .. can you share the exact errors, just like they appear on your output

lyuts
17th May 2009, 10:29
Are you sure this is a static lib? It says "DataIO is supplied as a DLL".

auba
17th May 2009, 10:56
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?