Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Satch on January 24, 2006, 02:52:51 am

Title: I feel stupid but... (SOLVED)
Post by: Satch on January 24, 2006, 02:52:51 am
First of all say HI!!!  :)

This is a question that makes me feel stupid since it is one of those asked trillion times and answered trillion times, but I failed to find that answer in the forums with the search tool above.

I'm using code::blocks with MSVC2003 toolkit and MSDK. To be sure all would work fine from start I  followed the MSVC toolkit integration tutorial to set up lib and include paths properly.

I tested the settings with a simple console project (yes, default compiler MSVC2003) and no problems compiling neither linking.
When I replaced the "main" identifier with "winmain" the problem shown up:

"error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup"

it's clear that it is a missing library, but can't figure out which one since the MSDK libraries paths are all correct (checked like 10 times).

Any help would be welcome and I beg your pardon if there's already a post about this issue elsewhere in the forums.

Thx in advance :)
Title: Re: I feel stupid but...
Post by: sethjackson on January 24, 2006, 03:12:04 am
First of all say HI!!!  :)

This is a question that makes me feel stupid since it is one of those asked trillion times and answered trillion times, but I failed to find that answer in the forums with the search tool above.

I'm using code::blocks with MSVC2003 toolkit and MSDK. To be sure all would work fine from start I  followed the MSVC toolkit integration tutorial to set up lib and include paths properly.

I tested the settings with a simple console project (yes, default compiler MSVC2003) and no problems compiling neither linking.
When I replaced the "main" identifier with "winmain" the problem shown up:

"error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup"

it's clear that it is a missing library, but can't figure out which one since the MSDK libraries paths are all correct (checked like 10 times).

Any help would be welcome and I beg your pardon if there's already a post about this issue elsewhere in the forums.

Thx in advance :)

Ok what version of C::B RC2, SVN-HEAD? Could you post some code and the libs you are linking in? You did include windows.h right...  :lol:

EDIT:

There is a template for Windows GUI programs too.  :wink:
Title: Re: I feel stupid but...
Post by: takeshimiya on January 24, 2006, 03:29:09 am
You need to change the "subsystem".

Menu Project->Properties->Targets tab.

In Select build target options->Type: change from "Console application" to "GUI application".

But anyways, I wonder why you want to use WinMain as the entry point. Are you programming with MFC?
Title: Re: I feel stupid but...
Post by: sethjackson on January 24, 2006, 03:31:20 am
You need to change the "subsystem".

Menu Project->Properties->Targets tab.

In Select build target options->Type: change from "Console application" to "GUI application".

But anyways, I wonder why you want to use WinMain as the entry point. Are you programming with MFC?

Uhh WinMain is for Win32 API programming....... Not MFC (AFAIK)......
Title: Re: I feel stupid but...
Post by: takeshimiya on January 24, 2006, 03:45:19 am
Uhh WinMain is for Win32 API programming....... Not MFC (AFAIK)......

It is used, but internally, AFAIK.
Title: Re: I feel stupid but...
Post by: sethjackson on January 24, 2006, 03:46:05 am
Uhh WinMain is for Win32 API programming....... Not MFC (AFAIK)......

It is used, but internally, AFAIK.

Ah I see.
Title: Re: I feel stupid but...
Post by: Michael on January 24, 2006, 10:32:20 am
AFAIK WinMain (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/winmain.asp) is used by Win32 API (independent of using MFC or not). Win32 API is a C API. MFC (http://en.wikipedia.org/wiki/Microsoft_Foundation_Classes) wraps portions of the Windows API in C++ classes. Normal C/C++ programs use main, but windows programs use WinMain.

Michael

[EDIT] A link about the Windows API (http://en.wikipedia.org/wiki/Windows_API) for all the fans of Windows :D.
Title: Re: I feel stupid but...
Post by: Satch on January 24, 2006, 10:42:30 am
Thx for the tips :)

I forgot about the templates... guess I was too tired when I posted the issue.
The problem was a bad declaration of winmain. Guess I've been using BCB for too long and I forgot the basics  :lol: :lol: :lol: :lol:

I must ask you for your forgiveness to take room in this forum for such stupid question  :(

Thx again for your help.
Title: Re: I feel stupid but...
Post by: Michael on January 24, 2006, 10:57:33 am
I must ask you for your forgiveness to take room in this forum for such stupid question  :(

IMHO there is no stupid question :D.

Michael