Where to find gettimeofday(), localtime()?

Mikey *jeffdb@netzone.nospam.com
Wed Jun 18 14:47:00 GMT 1997


It's almost always easier to let the compiler driver pick up
the appropriate libraries, the link line below should read

g++ -Wl,--verbose,--dll,-e,_dll_entry@12,--base-file=tmp.base -o DateTime.dll \
 Date.o DateTimePkgInit.o Month.o Time.o TinyTime.o WeekDay.o Year.o fixup.o -ltcl76

although in my specs file, I have added fixup.o to the startup files, as %{dll:/usr/local/lib/fixup.o}
and the other dll stuff to link as %{dll:--dll -e _dll_entry@12}

that way any time I am compiling a dll, all I have to do is use gcc -dll X.o y.o z.o and don't
have to worry about the details.

also I think you need to surround gettimeofday() and localtime() with

extern "C" {
struct tm *localtime(time_t *timer);
int gettimeofday(struct timeval*, struct timezone*);
}

but that I'm not sure of, see how it works.

also you need to produce and link in a .exp file
presumably DateTime.exp, otherwise you can't link with the .dll

 -970404/../../../../i386-cygwin32/lib/libcygwin.a(libcmain.o)(.text+0x1e):libcmain.cc: undefined reference to `WinMain@16'
this you can ignore, it won't stop the link, unless you don't have a 

int main()( return 0;}

in your fixup.c

On Wed, 18 Jun 1997 14:20:22 +0200 (MET DST), you wrote:

>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      geier@forwiss.uni-passau.de	
>D-94032 Passau                  http://www.uni-passau.de/~geier/
>
>-
>For help on using this list (especially unsubscribing), send a message to
>"gnu-win32-request@cygnus.com" with one line of text: "help".
>

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".



More information about the Cygwin mailing list