Handmade Hero»Forums»Code
Ian James
4 posts
Issues compiling, please help
I tried to build day 33's source code but received these three errors:
win32_handmade.cpp:(.text+0xae9): undefined reference to `__imp_StretchDIBits'
win32_handmade.cpp:(.text+0x1763): undefined reference to `__imp_timeBeginPeriod'
win32_handmade.cpp:(.text+0x18d7): undefined reference to `__imp_GetDeviceCaps'

I have tried to build other days and received the same errors. With day 23's source code, for instance, I received an error having to do with HANDMADE_INTERNAL not being passed and therefore the typedefs and stuff in the if for it were causing problems, but once I fixed that, I got the exact same errors I listed above.

Little more information, I am copying and pasting the code files into an empty project that was created by the program DevC++.

When I try to run build.bat, I receive the error "'cl' is not recognized as an internal or external command, operable program or batch file.". My gut says the environment isn't set up correctly, but I'm unsure as to how to proceed.

Any suggestions?
Mārtiņš Možeiko
2570 posts / 2 projects
Issues compiling, please help
This error means that linker doesn't know what are StretchDIBits, timeBegionPeriod and GetDeviceCaps functions. You either need to define them, or provide import libraries - *.lib files. Casey has showed multiple times how to know in what libraries functions are defined - you go to MSDN documentation for the function and look up Library entry. That will give you file name you need to add for linker.

StretchDIBits and GetDeviceCaps is provided by gdi32.lib library.
timeBeginPeriod is provided by winmm.lib library.

Now you need you just figure out how to pass these two libraries to linker. It is a bit different in each IDE.

Do yourself a favor and don't use DevC++ IDE. It is very bad and very old IDE. If you don't want to use Visual Studio IDE switch to something like Code::Blocks or QtCreator.

To use build.bat you need to first execute misc/shell.bat script. It sets up environment. So open new cmd.exe window and first execute shell.bat. Then you'll be able to run build.bat.
Ian James
4 posts
Issues compiling, please help
You, sir, are incredibly helpful, thank you.