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.

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 on other sites
i believe you need to download the Platform SDK before doing a Win32 app in VS 2005.

Share on other sites
where can i do that?

Share on other sites
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 on other sites
ok does doing this mess up any of my normal apps or does it just allow me to build win32 like in vc6.0 / vc2003?

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 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 causeA 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 on other sites
#include <windows.h>

Share on other sites
lol i added #include <windows.h> and now it works
did i even have to install the platform SDK.
jesus christ lol... well ty tons for all who helped

Share on other sites
Quote:
 Original post by jchmackdid 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 on other sites
Quote:
Original post by iMalc
Quote:
 Original post by jchmackdid 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 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.

Create an account

Register a new account

• Forum Statistics

• Total Topics
628758
• Total Posts
2984535

• 12
• 25
• 12
• 10
• 17