Weird linking problem

Programming, for all ages and all languages.
Post Reply
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Weird linking problem

Post 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!?
User avatar
JoeKayzA
Member
Member
Posts: 79
Joined: Wed Aug 24, 2005 11:00 pm
Location: Graz/Austria

Post 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
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post by earlz »

hmmm..brynet was right..
how the crap did it work on Windows XP then!?
User avatar
JoeKayzA
Member
Member
Posts: 79
Joined: Wed Aug 24, 2005 11:00 pm
Location: Graz/Austria

Post by JoeKayzA »

hckr83 wrote:hmmm..brynet was right..
... did I miss something :?:
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post 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..
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Tyler
Member
Member
Posts: 514
Joined: Tue Nov 07, 2006 7:37 am
Location: York, England

Post 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.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post 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... :roll:
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
iammisc
Member
Member
Posts: 269
Joined: Thu Nov 09, 2006 6:23 pm

Post 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
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post 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? :?
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Tyler
Member
Member
Posts: 514
Joined: Tue Nov 07, 2006 7:37 am
Location: York, England

Post 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.
iammisc
Member
Member
Posts: 269
Joined: Thu Nov 09, 2006 6:23 pm

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