Hi I get the common Undefined References error in CodeBlocks I am pretty sure The code is right.

case WM_PAINT:
		{
            BITMAP bm;
			PAINTSTRUCT ps;

			HDC hdc = BeginPaint(hwnd, &ps);

			HDC hdcMem = CreateCompatibleDC(hdc);
			HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, g_hbmAnime);

			GetObject(g_hbmAnime, sizeof(bm), &bm);

			BitBlt(hdc, 150, 100, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);

			SelectObject(hdcMem, hbmOld);
			DeleteDC(hdcMem);

			EndPaint(hwnd, &ps);
		}

compiler error:

obj\Debug\aimain.o:aimain.cpp:(.text+0x214)||undefined reference to `_CreateCompatibleDC@4'|
obj\Debug\aimain.o:aimain.cpp:(.text+0x22e)||undefined reference to `_SelectObject@8'|
obj\Debug\aimain.o:aimain.cpp:(.text+0x250)||undefined reference to `_GetObjectA@12'|
obj\Debug\aimain.o:aimain.cpp:(.text+0x29b)||undefined reference to `_BitBlt@36'|
obj\Debug\aimain.o:aimain.cpp:(.text+0x2b0)||undefined reference to `_SelectObject@8'|
obj\Debug\aimain.o:aimain.cpp:(.text+0x2be)||undefined reference to `_DeleteDC@4'|
||=== Build finished: 6 errors, 0 warnings ===|

anyone knows how to fix this ?

Recommended Answers

You need to link "gdi32.dll" into your project :)

Chris

Jump to Post

All 4 Replies

You need to link "gdi32.dll" into your project :)

Chris

where can i set that link and where do i get gdi32.dll ??

Project -> Build Options -> Linker -> add -> gdi32

Chris

thx will marking this as solved and hope this will help me for future references

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.