Subject: Where to find gettimeofday(), localtime()?
From: [email-masked] (Roland Geier)

18 Jun 1997 06:56:33 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Original-To: [email-masked]
X-Face: 
	 %JjDwL,CM#gbv*uICrNLdM9yk_LRxMh3DV'.fQ>iw'N;7([Jq}2|J#5o".kzM&>7tW`8T^Z
	 buvRLp?jvQ+sbD3BND%=&D: lT%vT4p7cGcGRP5JO+F'^
X-Mailer: ELM [version 2.4ME+ PL31 (25)]
Original-Sender: [email-masked]

Hi!

I'm currently working on a port of some date/time-Classes from Unix to
NT. The time-class 'class Time' uses the functions 'gettimeofday' and
'localtime'. Therefore I *do* include 'time.h' and 'sys/time.h' in the
'Time.cc'-source-file, but have to declare the functions 'localtime'
and 'gettimeofday' to be of external linkage explicitly to get the
file compiled without warnings:

-------------------- snip --------------------
:
:
#include <time.h>
#include <sys/time.h>

#ifdef  __CYGWIN32__
    extern struct tm *localtime(time_t *timer);
    extern int gettimeofday(struct timeval*, struct timezone*);
#endif
:
-------------------- snip --------------------

I guess that's not how it should be :-(. The subseqent link-call

> ld.exe --verbose --dll -o DateTime.dll -e _dll_entry@12 \
> -LC:\Programme\gnuwin32\b18\H-i386-cygwin32\lib\gcc-lib\i386-cygwin32\cygnus-2.7.2-970404 \
> -LC:/Programme/gnuwin32/b18/H-i386-cygwin32/lib/gcc-lib \
> -LC:/Programme/gnuwin32/b18/H-i386-cygwin32/lib/gcc-lib/i386-cygwin32/cygnus-2.7.2-970404/../../../../i386-cygwin32/lib \
> -LC:/Programme/gnuwin32/b18/H-i386-cygwin32/lib/gcc-lib/i386-cygwin32/cygnus-2.7.2-970404/../../.. \
> -LC:/Programme/gnuwin32/b18/H-i386-cygwin32/lib/gcc-lib/i386-cygwin32/cygnus-2.7.2-970404 \
> --base-file=tmp.base Date.o DateTimePkgInit.o Month.o Time.o TinyTime.o WeekDay.o Year.o fixup.o \
> libtcl76.a -lstdc++ -lcygwin -lgcc -lkernel32

to generate a dll produces the following undefined-reference-errors:

> Time.o: In function `Time::Initialize(void)':
> //majestix/geier/project/packages/cms++-2.0/src/types/Time.cc:62: undefined refe
> rence to `gettimeofday(timeval *, timezone *)'
> Time.o: In function `Time::Now(void)':
> //majestix/geier/project/packages/cms++-2.0/src/types/Time.cc:70: undefined refe
> rence to `gettimeofday(timeval *, timezone *)'
> Time.o: In function `Time::BreakDown(int &, WeekDay &, Month &, int &, int &, in
> t &, int &, int &) const':
> //majestix/geier/project/packages/cms++-2.0/src/types/Time.cc:99: undefined refe
> rence to `localtime(long *)'
> C:/Programme/gnuwin32/b18/H-i386-cygwin32/lib/gcc-lib/i386-cygwin32/cygnus-2.7.2
> -970404/../../../../i386-cygwin32/lib/libcygwin.a(libcmain.o)(.text+0x1e):libcma
> in.cc: undefined reference to `WinMain@16'

Could someone tell me what libraries are to be linked to get the two
time-related functions referenced correctly? What about the undefined
reference to 'WinMain@16'???

Thx in advance,

--- Roland.

---
Roland Geier                    Phone: ++49 (8505) 92181          
Universitaet Passau, GER 	Fax:   ++49 (8505) 922311
Lehrstuhl Prof. Dr. Donner      [email-masked]	
D-94032 Passau                  http://www.uni-passau.de/~geier/

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".