This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to link with third party libraries using gcc

I do a fair amount of C programming on Unix but almost none on Windows. I
know almost nothing about Windows libraries. I'd be happy if I never had to
deal with them at all. But I have a need. 

I thought Windows shared libraries were indentified by a ".dll" extension.
However I have a commercial product installed that has a C programming
interface. It's libraries have a ".lib" extension. I am totally lost as to
how to link my program to these files.

The Cygwin User's Guide contains an extremely brief section on linking
against DLL's (section 4.3.2). It shows how to use "nm" to create a  ".def"
file and then "dlltool" to create a ".a" file. I don't know how this relates
to the ".lib" files that I have.

The command given in the User's Guide create the ".def" file is as follows:

nm foo.dll | grep ' T _' | sed 's/.* T _//' >> foo.def

I don't have a ".dll" file but I noticed that my ".lib" files have lines
containing the string " T _" .  So I ran the above "nm" command using my
".lib" files. The resulting ".def" file won't work with the second step
which is:

dlltool --def foo.def --dllname foo.dll --output-lib foo.a

The error I get from the above command says that the ".def" file has
incorrect format.

In summary, I'm totally lost. I have no idea what's going on here. Does any
of this make sense to you guys.? Can you tell me how to link against a
".lib" file?


View this message in context:
Sent from the Cygwin Users mailing list archive at

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]