Linker Error Undefined Reference To Getstockobject 4
Specific Boards Windows Programming [Linker error] undefined reference to `GetStockObject@4' Getting started with C or C++ | C Tutorial | C++ Tutorial | C and C++ FAQ | Get a compiler | Fixes for common problems Thread: [Linker error] undefined reference to `GetStockObject@4' Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 03-29-2005 #1 willkoh View Profile View Forum Posts Registered User Join Date Jan 2005 Posts 70 [Linker error] undefined reference to `GetStockObject@4' This is a problem compiling a windows program with DevCPP. I have included
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the http://cboard.cprogramming.com/windows-programming/63630-[linker-error]-undefined-reference-%60getstockobject@4.html Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How do I link to libraries when compiling a win32 project with gcc? up vote 1 down vote favorite I am trying to http://stackoverflow.com/questions/12651202/how-do-i-link-to-libraries-when-compiling-a-win32-project-with-gcc compile a basic hello word winform application with gcc on Win 7. The code is this: /* WINHELLO.C "Hello, world!", Win32 style. */ #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss http://stackoverflow.com/questions/1340824/whats-up-with-getstockobject the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow https://bytes.com/topic/c/answers/876287-could-someone-please-help-me-fix-problem-ive-been-having-my-windows-gui Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each linker error other. Join them; it only takes a minute: Sign up What's up with “GetStockObject”? up vote 0 down vote favorite I've created a program in Eclipse / MinGW / C (project type: C) which should just present an empty window. It also has the folowing line: wndclassex.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); The call to GetStockObject() produces a compiler error: Z:/mtsts_workspace/MTSTS/Debug/../WinMain.c:29: undefined linker error undefined reference to `GetStockObject@4' Has anyone an idea what's wrong ? c windows eclipse share|improve this question edited Aug 27 '09 at 13:01 unwind 255k38332460 asked Aug 27 '09 at 12:40 Marcus Tik 2764927 add a comment| 2 Answers 2 active oldest votes up vote 5 down vote accepted Check the documentation, and make sure you link to the required libraries (gdi32). share|improve this answer answered Aug 27 '09 at 12:42 unwind 255k38332460 I have included windows.h And with Visual Studio the code was OK. –Marcus Tik Aug 27 '09 at 13:04 Including doesn't help; this is a link-type error. You need to specify that the code should be linked with gdi32.lib, where the actual code for GetStockObject() resides. –unwind Aug 27 '09 at 13:14 How can I "specify the code" that should be linked with gdi32.lib ??? Normaly I just put in the #include's and then simply call the functions ... –Marcus Tik Aug 27 '09 at 13:49 Add the library gdi32.lib to your Eclips
+ Ask a Question Need help? Post your question and get tips & solutions from a community of 418,582 IT Pros & Developers. It's quick & easy. Could someone please help me fix this problem i've been having with my Windows GUI. P: 2 muddy22 I'm only having a problem with a small part, i'm fairly new to computer programming and the program i'm using is Dev-C++. The part that i'm having a problem with is this: int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR CmdLine, int CmdShow); ;{ static WNDCLASS Wc; memset(&Wc,0,sizeof(Wc)); static MSG Msg; memset(&Msg,0,sizeof(Msg)); Wc.style=CS_HREDRAW | CS_VREDRAW; Wc.lpfnWndProc=WndProc; Wc.cbClsExtra=0; Wc.cbWndExtra=0; Wc.hInstance=hInst; Wc.hIcon=LoadIcon(NULL,IDI_WINLOGO); Errors: 54 C:\Users\Matthew\Dev-Cpp\Bouncing ball.cpp expected unqualified-id before '{' token 54 C:\Users\Matthew\Dev-Cpp\Bouncing ball.cpp expected `,' or `;' before '{' token Line 54 is the problem and it's the ";{" line. Please help me out with this problem, i honestly have no idea what i can do to fix it. Oct 30 '09 #1 Post Reply Share this Question 4 Replies Expert Mod 5K+ P: 8,916 Banfa Remove the ; at the end of the previous line and the beginning of that line 54. Make sure you have include Windows.h (directly or indirectly). Make sure you haven't #defined any symbols with clashing names. Oct 30 '09 #2 reply P: 2 muddy22 That didn't fix the problem, here is all of the work i've done. Expand|Select|Wrap|Line Numbers #include