Author Topic: I feel stupid but... (SOLVED)  (Read 6706 times)

Satch

  • Guest
I feel stupid but... (SOLVED)
« 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 :)
« Last Edit: January 24, 2006, 10:44:41 am by Satch »

sethjackson

  • Guest
Re: I feel stupid but...
« Reply #1 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:

takeshimiya

  • Guest
Re: I feel stupid but...
« Reply #2 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?

sethjackson

  • Guest
Re: I feel stupid but...
« Reply #3 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)......

takeshimiya

  • Guest
Re: I feel stupid but...
« Reply #4 on: January 24, 2006, 03:45:19 am »
Uhh WinMain is for Win32 API programming....... Not MFC (AFAIK)......

It is used, but internally, AFAIK.

sethjackson

  • Guest
Re: I feel stupid but...
« Reply #5 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.

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: I feel stupid but...
« Reply #6 on: January 24, 2006, 10:32:20 am »
AFAIK WinMain is used by Win32 API (independent of using MFC or not). Win32 API is a C API. MFC 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 for all the fans of Windows :D.
« Last Edit: January 24, 2006, 10:35:47 am by Michael »

Satch

  • Guest
Re: I feel stupid but...
« Reply #7 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.

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: I feel stupid but...
« Reply #8 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