Sign in to follow this  

new win32 project in visual studio 2005

This topic is 4382 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok im trying to switch from visual studio 6.0 and opengl to visual studio 2005 and directx. I can create a new console app fine but when i try to make a non-console win32 project i cant even get a blank main function to compile right. heres what i do: open vs2005 start a new win32 project make it an empty project add a new cpp file and try to compile this code
int WINAPI WinMain(	HINSTANCE	hInstance,		// Instance
			HINSTANCE	hPrevInstance,		// Previous Instance
			LPSTR		lpCmdLine,		// Command Line Parameters
			int		nCmdShow)		// Window Show State
{
	return true;
}


and i get these errors: MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup isnt this how u start a basic win32 project?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Instructions for compiling Win32 projects with Visual Studio express are at:
http://lab.msdn.microsoft.com/express/visualc/usingpsdk/default.aspx
This will tell you how to install the Win32Platform SDK at to reactivate the Win32 compilation options in VSExpress - the ability is still there, it's just deactivated be default.
After that start a new project using the Win32 Console project wizard - before accepting at the last wizard screen go to the Application Settings tab and click the Windows Application radio button.

Share this post


Link to post
Share on other sites
ok now i try compiling the code above and get these errors:

1>------ Build started: Project: corewin, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>c:\documents and settings\julius abella\my documents\visual studio 2005\projects\corewin\corewin\main.cpp(2) : error C2146: syntax error : missing ';' before identifier 'WinMain'
1>c:\documents and settings\julius abella\my documents\visual studio 2005\projects\corewin\corewin\main.cpp(2) : error C2065: 'HINSTANCE' : undeclared identifier
1>c:\documents and settings\julius abella\my documents\visual studio 2005\projects\corewin\corewin\main.cpp(2) : error C2146: syntax error : missing ')' before identifier 'hInstance'
1>c:\documents and settings\julius abella\my documents\visual studio 2005\projects\corewin\corewin\main.cpp(2) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\julius abella\my documents\visual studio 2005\projects\corewin\corewin\main.cpp(5) : error C2059: syntax error : ')'
1>c:\documents and settings\julius abella\my documents\visual studio 2005\projects\corewin\corewin\main.cpp(6) : error C2143: syntax error : missing ';' before '{'
1>c:\documents and settings\julius abella\my documents\visual studio 2005\projects\corewin\corewin\main.cpp(6) : error C2447: '{' : missing function header (old-style formal list?)
1>Build log was saved at "file://c:\Documents and Settings\Julius Abella\My Documents\Visual Studio 2005\Projects\corewin\corewin\Debug\BuildLog.htm"
1>corewin - 7 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

and btw im using:

Microsoft Visual Studio 2005
Version 8.0.50727.42 (RTM.050727-4200)
Microsoft .NET Framework
Version 2.0.50727

Installed Edition: Professional

Microsoft Visual Basic 2005 77626-009-0000007-41909
Microsoft Visual Basic 2005

Microsoft Visual C# 2005 77626-009-0000007-41909
Microsoft Visual C# 2005

Microsoft Visual C++ 2005 77626-009-0000007-41909
Microsoft Visual C++ 2005

Microsoft Visual J# 2005 77626-009-0000007-41909
Microsoft Visual J# 2005

Microsoft Visual Web Developer 2005 77626-009-0000007-41909
Microsoft Visual Web Developer 2005

Crystal Reports AAC60-G0CSA4B-V7000AY
Crystal Reports for Visual Studio 2005

Share this post


Link to post
Share on other sites
#include <windows.h>

You should really try reading your error messages. In addition to telling you that something is wrong, they tell you what is wrong, and each error message has a corresponding MSDN page that details common causes and resolutions. Your first error, for instance, reads:
error C2146: syntax error : missing ';' before identifier 'WinMain'

The MSDN page for C2146 says:
Quote:
Probable cause
  • A typographical error. Error C2065 usually precedes this error.

The example it provides barfs on a misspelling of int as intt; in your code, WinMain is preceded by WINAPI. Why would the compiler not recognize WINAPI? Because it's not part of the C or C++ languages. It's something that's defined somewhere, and you forgot to tell the compiler where.

Share this post


Link to post
Share on other sites
Quote:
Original post by jchmack
did i even have to install the platform SDK.
Actually, yes.
Don't expect everything to work perfectly though. You're still prone to getting a ton of linker errors I found. Specifically, you may need to turn off some of the new security buffer checks etc. And I still cant for the life of me figure out how to solve the undefined symbols from using strstream(s).

Share this post


Link to post
Share on other sites
Quote:
Original post by iMalc
Quote:
Original post by jchmack
did i even have to install the platform SDK.
Actually, yes.
Don't expect everything to work perfectly though. You're still prone to getting a ton of linker errors I found. Specifically, you may need to turn off some of the new security buffer checks etc. And I still cant for the life of me figure out how to solve the undefined symbols from using strstream(s).

Actually, no:
Quote:

Installed Edition: Professional

Professional and Standard versions ship with a pre-installed PSDK.

Share this post


Link to post
Share on other sites

This topic is 4382 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this