By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,971 Members | 1,732 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,971 IT Pros & Developers. It's quick & easy.

Problem with MSVC++.NET 2003 Project converted to 2005

P: n/a
Hi all, would appreciate help with some trouble I'm having after using the
Visual C++ 2005 Express Conversion Wizard on my Visual C++ .NET 2003
project.

The wizard completed successfully with only warnings about using a "fully
qualified name with the use of the address-of operator (e.g.
&ClassName::MemberFunctionName)". I added the & operator as needed and
eliminated the compile errors relating to those warnings.

The problem I am facing now is in the .cpp file associated with my form
(MainForm.cpp). The MainForm.cpp in 2003 .NET contained a '#include
<windows.h>' line, which will not compile, since windows.h does not seem to
come with Visual C++ 2005 Express.

If I comment out the windows.h include, the compilation fails at the
entrypoint function in MainForm.cpp:

int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threading::Thread::CurrentThread->ApartmentState =
System::Threading::ApartmentState::STA;
Application::Run(new MainForm());
return 0;
}

I presume that a lot of the structures defined in the function arguments
above depend on windows.h.

I can of course comment out the entrypoint function, which allows the
compiler to successfully terminate. But as expected, the linker will fail
as it cannot find an entrypoint:

Error 1 error LNK2019: unresolved external symbol _WinMain@16 referenced
in function ___tmainCRTStartup MSVCRT.lib

I am sure this is a fairly common problem, but I am stuck!
Jan 1 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

"Airw0lf" <ma*@the.world> wrote in message
news:Xn**********************@216.196.97.131...
Hi all, would appreciate help with some trouble I'm having after using the
Visual C++ 2005 Express Conversion Wizard on my Visual C++ .NET 2003
project.

The wizard completed successfully with only warnings about using a "fully
qualified name with the use of the address-of operator (e.g.
&ClassName::MemberFunctionName)". I added the & operator as needed and
eliminated the compile errors relating to those warnings.

The problem I am facing now is in the .cpp file associated with my form
(MainForm.cpp). The MainForm.cpp in 2003 .NET contained a '#include
<windows.h>' line, which will not compile, since windows.h does not seem
to
come with Visual C++ 2005 Express.

If I comment out the windows.h include, the compilation fails at the
entrypoint function in MainForm.cpp:

int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threading::Thread::CurrentThread->ApartmentState =
System::Threading::ApartmentState::STA;
Application::Run(new MainForm());
return 0;
}

I presume that a lot of the structures defined in the function arguments
above depend on windows.h.

I can of course comment out the entrypoint function, which allows the
compiler to successfully terminate. But as expected, the linker will fail
as it cannot find an entrypoint:

Error 1 error LNK2019: unresolved external symbol _WinMain@16 referenced
in function ___tmainCRTStartup MSVCRT.lib

I am sure this is a fairly common problem, but I am stuck!


I believe your problem is that the project template you used in VS 2003 is
not supported in VC++ 2005 Express. Your reference to "windows.h" leads me
to believe that the original project was a Win 32 standalone project? I
don't have VC++ 2005 Express installed here, but when you look at available
C++ project templates, is Win 32 included?
You *may* be able to install the necessary support for your Win 32 project
by downloading the .NET Framework 2.0 SDK here:

http://www.microsoft.com/downloads/d...DisplayLang=en
Jan 1 '06 #2

P: n/a
"pvdg42" <pv****@newsgroups.nospam> wrote in
news:O7**************@TK2MSFTNGP09.phx.gbl:

I believe your problem is that the project template you used in VS
2003 is not supported in VC++ 2005 Express. Your reference to
"windows.h" leads me to believe that the original project was a Win 32
standalone project? I don't have VC++ 2005 Express installed here, but
when you look at available C++ project templates, is Win 32 included?
You *may* be able to install the necessary support for your Win 32
project by downloading the .NET Framework 2.0 SDK here:

http://www.microsoft.com/downloads/d...fe6f2099-b7b4-
4f47-a244-c96d69c35dec&DisplayLang=en


Thanks for the reply, but I am slightly confused. My project under 2003 was
not a Win32 standalone project, it needed the 1.1 .NET framework in order
to run. It was a CLR (common language runtime) Windows Forms application.
And as you can see from the entrypoint function, the .NET class library is
being used. For example:

System::Threading::Thread::CurrentThread->ApartmentState =
System::Threading::ApartmentState::STA;

Those are .NET namespaces. All of my other code also references the .NET
class library, and will compile fine (assuming the problem main function is
commented out).

My feeling is that Microsoft have changed how the winmain function works
from the old .NET 2003/ 1.1 Framework. But for some reason the Conversion
Wizard doesn't seem to do anything about it.

But I wonder if the .NET Framework 2.0 SDK will help. Will it contain
windows.h for example. I am guessing that my old copy of MS Visual Studio
2003 .NET would have included the full .NET SDK. Visual Studio Express does
not have the SDK of course...But a 350 meg download seems to be a lot for a
little problem like this!
Jan 1 '06 #3

P: n/a
"pvdg42" <pv****@newsgroups.nospam> wrote in
news:O7**************@TK2MSFTNGP09.phx.gbl:

I believe your problem is that the project template you used in VS
2003 is not supported in VC++ 2005 Express. Your reference to
"windows.h" leads me to believe that the original project was a Win 32
standalone project? I don't have VC++ 2005 Express installed here, but
when you look at available C++ project templates, is Win 32 included?
You *may* be able to install the necessary support for your Win 32
project by downloading the .NET Framework 2.0 SDK here:

http://www.microsoft.com/downloads/d...fe6f2099-b7b4-
4f47-a244-c96d69c35dec&DisplayLang=en


I got it working with the Platform SDK, which contains windows.h in the
/include directory.

It's really quite strange, I created a test Windows Forms CLR project in
2005 Express, and windows.h is not referenced at all, and the entrypoint
function is completely different.

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are
created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(fal se);

// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}

If I replace the winmain in my project with the above, the compiler
doesn't seem to understand the 'array' keyword. It must have something to
do with the type of project, although both projects are supposed to be
Windows Forms CLR projects! All I can think of is that the Conversion
Wizard does not "fully" convert 2003 CLR Forms projects to the 2005
version, and that you are forced to rely on the platform SDK for
windows.h and the old entrypoint function.

All other code and resources port over with virtually no fuss.

If anyone can shed further light on the differences, I'd really welcome
it.
Jan 2 '06 #4

P: n/a

"Airw0lf" <ma*@the.world> wrote in message
news:Xn**********************@216.196.97.131...
"pvdg42" <pv****@newsgroups.nospam> wrote in
news:O7**************@TK2MSFTNGP09.phx.gbl:
Thanks for the reply, but I am slightly confused. My project under 2003
was
not a Win32 standalone project, it needed the 1.1 .NET framework in order
to run. It was a CLR (common language runtime) Windows Forms application.
And as you can see from the entrypoint function, the .NET class library is
being used. For example:

As you didn't specify which version you're using, I took a chance and
referred you to the v2.0 SDK. As you're using VS 2003, the v1.1 would, of
course, apply.
Jan 2 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.