This is the mail archive of the 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]

RE: Can I build a windows dll and lib from cygwin

There is a living and breathing example of building
a C DLL on the Cygwin site under "DLL STUFF" at

I was able to kludge the example makefile in the "c" directory
(see below) with RSI's IDL C external calling example to give an
instance of IDL calling a *.c DLL using Cygwin GCC.

Obviously you should go through the Readme and so-on on the "DLL STUFF"
page; however, cutting right to the chase...
1. on Cygwin
 $ mkdir  /usr/src/dllhelpers-0.2.9
2. Back at the "DLL STUFF" page find "dllhelpers-0.2.9.tar.bz2"
(which is
-0.2.9.tar.bz2 )
and use Save As to put it into [~approx~C:\Cygwin]\usr\src\dllhelpers-0.2.9
3. on Cygwin
 $ cd /usr/src/dllhelpers-0.2.9
 $ bunzip2 dllhelpers-0.2.9.tar.bz2
 $ tar tvf dllhelpers-0.2.9.tar <----have a look first!!
 $ tar xvf dllhelpers-0.2.9.tar
 $ cd c
<begin real stuff...>
Administrator@LEAMAN /usr/src/dllhelpers-0.2.9/c
$ make
gcc -c  -I. -g -Wall  -o cdll.o cdll.c
gcc -shared -Wl,--out-implib=libcdll.dll.a \
-o cygcdll.dll cdll.o  -Wl,--export-all-symbols
Creating library file: libcdll.dll.a
gcc -c -I. -g -Wall  -o usedll.o usedll.c
gcc -o usedll.exe -g -Wall   usedll.o -L./ -lcdll
Warning: resolving _dll_global_int_var by linking to
__imp__dll_global_int_var (auto-import)

Administrator@LEAMAN /usr/src/dllhelpers-0.2.9/c
$ ./usedll
dll_int_square (3) = 9
dll_float_square (3.0) = 9.000000
dll_double_square (3.0) = 9.000000
Global integer variable: Should be 99
  directly                  : 99
<end real stuff...>

Thanks, John

-----Original Message-----
From: []
Sent: Friday, 18 January 2002 1:52 p.m.
Subject: Can I build a windows dll and lib from cygwin

As I am only just getting into cygwin, I would like to know if it is
possible to 
build a block of unix code (just console applications) and produce a dll
can be called by windows applications.
I have done this following the advice on the cygwin sites and produce the 2 
files which i thought i needed these are foo.a (renamed to foo.lib below)
When I try to build a windows application linking to foo.a i get an error
the lib file can not be understood.
Have misunderstood the objective of the dll tool is it only to build apps on

I am using an application called matlab to build this file and get the
echo returned

Microsoft (R) 32-Bit Incremental Linker Version 5.00.7022 
Copyright (C) Microsoft Corp 1992-1997. All rights reserved. 
vistaread_mex.obj foo.lib mexversion.res  
vistaread_mex.obj : error : Internal error during Pass1

Does this mean anything to anyone?
Mr. S. Wood,
Research assistant

Dept Medical Physics & Clinical Engineering
I floor
Royal Hallamshire Hospital
Glossop road,
S10 2JF

Unsubscribe info:
Bug reporting:

Unsubscribe info:
Bug reporting:

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