Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@sources.redhat.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@sources.redhat.com>
List-Help: <mailto:cygwin-help@sources.redhat.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@sources.redhat.com
Delivered-To: mailing list cygwin@sources.redhat.com
X-Authentication-Warning: hp2.xraylith.wisc.edu: khan owned process doing -bs
Date: Wed, 11 Jul 2001 16:03:15 -0500 (CDT)
From: Mumit Khan <khan@NanoTech.Wisc.EDU>
Reply-To: Mumit Khan <khan@NanoTech.Wisc.EDU>
To: Robert Cordingley <cord@ragesoft.com>
cc: cygwin@cygwin.com
Subject: Re: error trying to build very simple dll 
In-Reply-To: <5.1.0.14.2.20010711145916.00aa2d60@earth.he.net>
Message-ID: <Pine.HPP.3.96.1010711155626.4332B-100000@hp2.xraylith.wisc.edu>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII

On Wed, 11 Jul 2001, Robert Cordingley wrote:

> Trying to build a very simple little dll, I get the following error:
> 
> $ dlltool --def gettz.def --output-exp gettz.exp --output-lib gettz.a 
> --dllname gettz.dll
> $ gcc -c gettz.c
> $ ld -o gettz.dll gettz.exp gettz.o

First rule of using gcc on any platform -- unless you have a very good
reason and know what you're doing, never use "ld" to link, but *always* 
use gcc or one of the other compiler drivers. Following this rule is 
even more important on platforms such as linux (if you want correct 
dynamic linker linked in), Cygwin (if you want correct libraries linked 
in), etc.

That said, you can do the following to build your DLL.

  $ gcc -c gettz.c
  $ gcc -shared -o gettz.dll -Wl,--out-implib,gettz.a gettz.def gettz.o

I'm assuming that you already have a proper gettz.def; if not, you can
either (1) use __declspec(dllexport), or (2) create one by hand.

> ld: warning: cannot find entry symbol _mainCRTStartup; defaulting to 00401000
> gettz.o(.text+0xc):gettz.c: undefined reference to `time'
> gettz.o(.text+0x20):gettz.c: undefined reference to `localtime'
> gettz.o(.text+0x28):gettz.c: undefined reference to `_imp___tzname'

These show up because you are using ld, and it doesn't know what system
libraries to link in.

Regards,
Mumit




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

