Take the 2-minute tour ×

I just installed Codeblocks on my new PC, now I'm trying to get a library running called CML(its a library from school and it's not very good) but I'm getting a strange error when i try to run some very basic example code. its not the code itself in Devcpp it compiles just fine.

The Error:

d:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libcml.a(video.o):video.c|| undefined reference to sleep'|

Does anyone know how i can fix this?

share|improve this question
Could you post a small example of code causing the error? –  gustavodidomenico Mar 13 '13 at 21:49
MinGW (or rather Windows) does not have a function sleep, only Sleep. Typo? –  Damon Mar 13 '13 at 21:49
no i dont even use sleep. –  Timtim32 Mar 13 '13 at 21:52
And i'm sure its not the code because in devcpp it compiles just fine –  Timtim32 Mar 13 '13 at 21:55
I just looked in the <unistd.h> that comes with my MinGW (4.7.2). It has a prototype for usleep (presumably wraps Sleep) but not sleep. Makes me wonder how they compiled that library in the first place... –  Damon Mar 13 '13 at 22:00
show 1 more comment

1 Answer

Damon is right the WinAPI only provides a function called Sleep. The error looks like the linker can't find this symbol in the libraries you are linking to.

A first guess would be that you have to add


to your linker command line. However, as far as I recall the Devcpp IDE should add this library by default...

share|improve this answer
That would be -lkernel32, not -lwinmm (and yes, this is default), but still this won't solve the issue of sleep and Sleep being different symbols. –  Damon Mar 13 '13 at 22:07
-lWinmm did not do the trick but i know that devcpp uses mingw 3.4.2 and CodeBlocks uses 4.7.2 maybe thats the problem? –  Timtim32 Mar 13 '13 at 22:08
add comment

Your Answer


