New to MinGW -- One Issue

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

New to MinGW -- One Issue

Richard C. Wagner
Hello Everyone:

I'm brand new to the list.  I've recently installed MinGW on my computer and
I'm making my first tests using it.  I'm trying to compile a C program, and
in initializing a window class structure I'm calling GetStockObject.  The
code looks like this:

wndClass.hBrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);

I'm getting a message from the compiler that makes it sound as if the
function is undefined: "undefined reference to 'GetStockObject@4'".  I'm
compiling under Windows XP.  Can anyone tell me what's wrong?


Thanks,

Rich Wagner
Aerospace Engineer
Montrose, CO, USA


------------------------------------------------------------------------------

_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: New to MinGW -- One Issue

DouglasA1
Give this a try first. It comes from a sample that I have called Win32_GUI

/* Use Windows's default colour as the background of the window */
wndClass.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
Good Luck!

On 5/13/10, Richard C. Wagner <[hidden email]> wrote:

> Hello Everyone:
>
>  I'm brand new to the list.  I've recently installed MinGW on my computer and
>  I'm making my first tests using it.  I'm trying to compile a C program, and
>  in initializing a window class structure I'm calling GetStockObject.  The
>  code looks like this:
>
>  wndClass.hBrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
>
>  I'm getting a message from the compiler that makes it sound as if the
>  function is undefined: "undefined reference to 'GetStockObject@4'".  I'm
>  compiling under Windows XP.  Can anyone tell me what's wrong?
>
>
>  Thanks,
>
>  Rich Wagner
>  Aerospace Engineer
>  Montrose, CO, USA
>
>
>  ------------------------------------------------------------------------------
>
>  _______________________________________________
>  MinGW-users mailing list
>  [hidden email]
>
>  This list observes the Etiquette found at
>  http://www.mingw.org/Mailing_Lists.
>  We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.
>
>  _______________________________________________
>  You may change your MinGW Account Options or unsubscribe at:
>  https://lists.sourceforge.net/lists/listinfo/mingw-users
>

------------------------------------------------------------------------------

_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: New to MinGW -- One Issue

Greg Chicares
In reply to this post by Richard C. Wagner
On 2010-05-13 20:14Z, Richard C. Wagner wrote:
>
> I'm getting a message from the compiler that makes it sound as if the
> function is undefined: "undefined reference to 'GetStockObject@4'".  I'm
> compiling under Windows XP.  Can anyone tell me what's wrong?

The message is from the linker. To determine which library to add
to the linker command, search for the function on msdn:
  http://msdn.microsoft.com/en-us/library/dd144925%28VS.85%29.aspx
It says "Gdi32.dll", so add '-lgdi32' at the end.

------------------------------------------------------------------------------

_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: New to MinGW -- One Issue

Earnie Boyd
Greg Chicares wrote:

> On 2010-05-13 20:14Z, Richard C. Wagner wrote:
>>
>> I'm getting a message from the compiler that makes it sound as if the
>> function is undefined: "undefined reference to 'GetStockObject@4'".  I'm
>> compiling under Windows XP.  Can anyone tell me what's wrong?
>
> The message is from the linker. To determine which library to add
> to the linker command, search for the function on msdn:
>    http://msdn.microsoft.com/en-us/library/dd144925%28VS.85%29.aspx
> It says "Gdi32.dll", so add '-lgdi32' at the end.
>

No one remembers what -mwindows is for?

--
Earnie
-- http://www.for-my-kids.com

------------------------------------------------------------------------------

_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: New to MinGW -- One Issue

Greg Chicares
On 2010-05-13 21:18Z, Earnie wrote:

> Greg Chicares wrote:
>> On 2010-05-13 20:14Z, Richard C. Wagner wrote:
>>>
>>> I'm getting a message from the compiler that makes it sound as if the
>>> function is undefined: "undefined reference to 'GetStockObject@4'".  I'm
>>> compiling under Windows XP.  Can anyone tell me what's wrong?
>>
>> The message is from the linker. To determine which library to add
>> to the linker command, search for the function on msdn:
>>    http://msdn.microsoft.com/en-us/library/dd144925%28VS.85%29.aspx
>> It says "Gdi32.dll", so add '-lgdi32' at the end.
>
> No one remembers what -mwindows is for?

I was trying to demonstrate a general method for resolving undefined
references to functions provided by the operating system.

But it did feel weird to type '-lgdi32'. I was kind of wondering how I
could have gone so many years without ever typing that, so thanks for
pointing out what had slipped my mind.

------------------------------------------------------------------------------

_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: New to MinGW -- One Issue

Richard C. Wagner
In reply to this post by Greg Chicares
Greg and Earnie:

Thanks for your replies.  "-mwindows" did the trick.  And I've found the
documentation (file /info/gcc.info) in the current MinGW release where the
gcc -m options are described.  If I had read that before compiling, I still
wouldn't have known to use it.  So thanks for your input.


Rich Wagner


------------------------------------------------------------------------------

_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users