This is the mail archive of the
mailing list for the GCC project.
Re: Easy linker problem
"Walliss, Darren" wrote:
> I want to use function 'sleep' in a program.
> When I compile my test prog with < gcc sleepTest.c -o sleepTest
> -mno-cygwin >
Using -mno-cygwin is the same as using MinGW, that is, you are using
MSVCRT.DLL as your C library. There is no such function "sleep()" in
MSVCRT. There is the win32 API function "Sleep()" (note case) which is
what you should use. There is an old deprecated and unsupported
"_sleep()" in MSVCRT but you should not use that.
> - how do I know which lib to use an a given situation, is there a
> reference out there somewhere??
The entire win32 API is documented quite well on MSDN, and each function
tells you precisely what header to include and what library to link
against. You can directly translate what MSDN says for "link against
foo.lib" to -lfoo on the gcc link command line. But the common system
libraries (-lkernel32 -luser32 -ladvapi32 -lshell32) are included in the
specs file by default so you don't need to manually link against those.