Page 1 of 1
Weird linking problem
Posted: Sun Mar 11, 2007 4:40 pm
by earlz
I have recently got MinGW and such to compile my projects on my new PC(running Vista)
I copied sdl into lib, and copied all those header files in include, so all of my projects, almost compile...
It says it has an undefined reference to sleep() which I am almost sure, is in there somewhere...so how the crap is it not!? isn't it part of LibC!?
if it's not in libc or whatnot then what lib is it in!?
Posted: Sun Mar 11, 2007 4:49 pm
by JoeKayzA
Did it work with other versions of windows?
After a short google search: MS's C library (msvcrt.dll) doesn't provide a sleep() function. There is a _sleep() function, which is deprecated however, and a Sleep() function provided by the Win32 API. Sorry, it seems you have to provide a platform dependent wrapper for that function, or use a different C library on windows (such as cygwin's).
cheers
Joe
Posted: Sun Mar 11, 2007 4:54 pm
by earlz
hmmm..brynet was right..
how the crap did it work on Windows XP then!?
Posted: Tue Mar 13, 2007 6:22 am
by JoeKayzA
hckr83 wrote:hmmm..brynet was right..
... did I miss something
Posted: Tue Mar 13, 2007 8:28 am
by Brynet-Inc
JoeKayzA wrote:hckr83 wrote:hmmm..brynet was right..
... did I miss something
Not really, He just asked me on IM and I said practically the same thing as you..
Posted: Tue Mar 13, 2007 9:48 am
by Tyler
JoeKayzA wrote:Did it work with other versions of windows?
After a short google search: MS's C library (msvcrt.dll) doesn't provide a sleep() function. There is a _sleep() function, which is deprecated however, and a Sleep() function provided by the Win32 API. Sorry, it seems you have to provide a platform dependent wrapper for that function, or use a different C library on windows (such as cygwin's).
cheers
Joe
Why would MinGW link to msvcrt.dll? Would it not provide its own port of the GNU C Library as other Compilers do? It seems very unlikely they would link to microsoft specific C Library. This would mean they could not provide static linkage without paying microsoft to ship the msvcrt.lib along with the MinGW package.
Posted: Tue Mar 13, 2007 10:05 am
by Brynet-Inc
Tyler wrote:Why would MinGW link to msvcrt.dll? Would it not provide its own port of the GNU C Library as other Compilers do? It seems very unlikely they would link to microsoft specific C Library. This would mean they could not provide static linkage without paying microsoft to ship the msvcrt.lib along with the MinGW package.
Because MinGW is not Cygwin.. MinGW is used to write native applications for Windows.. (
Not provide a POSIX/Unix compatibility layer..)
MinGW: import libraries and header files for use with GCC to build native Windows applications..
A package called (
w32api-3.8.tar.gz) is provided to interface with the Windows API.. header wrappers.. libraries etc.
So Microsoft's msvcrt.lib is not included.. a Free library is.. Which pretty much just provides anything required for resulting binaries to use the included msvcrt.dll distributed with Windows.. (
It includes a bunch of static .a libraries which are apparently just wrappers for the proprietary DLL's included with Windows..)
It's not a project like Cygwin which is trying to bring in support for functions found on POSIX complaint systems..
People should "
Really" just use Unix-like systems already...
Posted: Tue Mar 13, 2007 6:43 pm
by iammisc
i don't know if you know that glibc works on linux because it has been ported to work on linux. But on windows, i don't think microsoft releases how the c library uses the kernel so yes you HAVE to linux to msvcrt.dll. Even cygwin has to eventually do this or it has to linux to some other windows dll
Posted: Tue Mar 13, 2007 7:02 pm
by Brynet-Inc
iammisc wrote:i don't know if you know that glibc works on linux because it has been ported to work on linux. But on windows, i don't think microsoft releases how the c library uses the kernel so yes you HAVE to linux to msvcrt.dll. Even cygwin has to eventually do this or it has to linux to some other windows dll
I didn't understand a word you said.. did you confuse Link/Linux a few times?
Posted: Tue Mar 13, 2007 8:04 pm
by Tyler
iammisc wrote:i don't know if you know that glibc works on linux because it has been ported to work on linux. But on windows, i don't think microsoft releases how the c library uses the kernel so yes you HAVE to linux to msvcrt.dll. Even cygwin has to eventually do this or it has to linux to some other windows dll
I think you started to make a point that it has to use msvcrt because programs do not know how to use the System Call ABI... of course this would be impossible anyway as it is different for each version of windows. Then you seem to backtrack and realise that the Windows API could also be wrappered and basically make my point, MinGW can use it's own C Library not msvcrt. I am sure M$ wrap the Win32 API also.
Posted: Sun Mar 18, 2007 3:59 pm
by iammisc
I didn't understand a word you said.. did you confuse Link/Linux a few times
yes i did. i meant this
i don't know if you know that glibc works on linux because it has been ported to work on linux. But on windows, i don't think microsoft releases how the c library uses the kernel so yes you HAVE to link to msvcrt.dll. Even cygwin has to eventually do this or it has to link to some other windows dll.
Sorry. i wrote this late at night.