Handmade Hero»Forums»Code
David
2 posts
Day 11, error LNK2019: unresolved external symbol
This might be more in the wheelhouse of build problems, but I've gotten some big problems as of video 11.

Since I don't like emacs, I initially just started this project as a Visual Studios project, but VS started dying once the project started getting broken off into multiple files.

So I switched to Atom editor, replaced my files with Casey's versions, and built it in atom, but ran into some errors specifically around StretchDIBits and PatBlt.

Here's the error output:
Executing: C:\Users\David\Documents\handmade\handmade\code\build.bat
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x64
Copyright (C) Microsoft Corporation. All rights reserved.

win32_handmade.cpp
Microsoft (R) Incremental Linker Version 12.00.31101.0
Copyright (C) Microsoft Corporation. All rights reserved.

/out:win32_handmade.exe
/debug
win32_handmade.obj
user32.lib
win32_handmade.obj : error LNK2019: unresolved external symbol __imp_StretchDIBits referenced in function "void __cdecl Win32DisplayBufferInWindow(struct win32_offscreen_buffer *,struct HDC__ *,int,int)" (?Win32DisplayBufferInWindow@@YAXPEAUwin32_offscreen_buffer@@PEAUHDC__@@HH@Z)
win32_handmade.exe : fatal error LNK1120: 1 unresolved externals


my win32_handmade.ccp and handmade.ccp are idential to Casey's version

Here is my modified batch.bat(to account for using Atom):
@echo off
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64
cd build
cl -Zi ..\code\win32_handmade.cpp user32.lib



Thanks!
Mārtiņš Možeiko
2559 posts / 2 projects
Day 11, error LNK2019: unresolved external symbol
Edited by Mārtiņš Možeiko on
Similar thing happened on Day 2 when Casey wanted to use PatBlt function. See ~51:00. He got linker error that PatBlt function is not found. So he showed how to fix that - by adding gdi32.lib library where it is defined (you can now where Windows function is defined by looking it up in MSDN docs).

So you need to add gdi32.lib library to your linker input - next to user32.lib library (for Visual Studio that would be Project Properties -> Linker -> Input -> Additional Dependencies).