Re: Easy linker problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"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.

<http://msdn.microsoft.com/library/en-us/dllproc/base/sleep.asp>

> - 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.

Brian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux