Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't make API calls

Status
Not open for further replies.

CNewbie

Programmer
Dec 20, 2001
18
US
Hi, I'm a C/C++ beginner and I can't get any API calls to run (I have previously used API with VB). Here is a sample code that won't work :

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, &quot;Goodbye, cruel world!&quot;, &quot;Note&quot;, MB_OK);
return 0;
}

I get the error unresolved external _main reference. I tried Borland C++ 5.02 and Microsoft Visual C++ 6.0. It compiles on both but I get the error when I run it.
Please help me.
 
Hi,

you must add the option: &quot;-subsystem:windows&quot; (without the quotes) to the link command. Marcel
 
Thanx, I manage to find it under visual C++ but I can't find it under borland C++. It the option menu there is a tab for linker but I don't know witch checkbox is the equivalent of -subsystem:windows. Anyway, I still get an error in Visual C++ : c:\program files\microsoft visual studio\myprojects\MyProject\MyProject.cpp(4) : fatal error C1083: Cannot open precompiled header file: 'Debug/MyProject.pch': No such file or directory
Error executing cl.exe.

What does that means.

Thanx a lot for the help. Getting started is always the hardest part.
 
Thanx, I manage to find it under visual C++ but I can't find it under borland C++. It the option menu there is a tab for linker but I don't know witch checkbox is the equivalent of -subsystem:windows. Anyway, I still get an error in Visual C++ : c:\program files\microsoft visual studio\myprojects\MyProject\MyProject.cpp(4) : fatal error C1083: Cannot open precompiled header file: 'Debug/MyProject.pch': No such file or directory
Error executing cl.exe.

What does that means.

Thanx a lot for the help. Getting started is always the hardest part.
 
Mmmm - did you start out by making a VC6 simple win32
application of the 'A simple Win32 Application' or
'A typical hello World application' type and then messed
it around to make it as simple as possible by
removing the StdAfx.cpp and StdAfx.h files???
If so then you will get the can't find *.pch file.
PCH files are precompiled header files.

In that case go to Project Settings -> C++ tab.
Select the 'Precompiled headers' category.
and set 'Not using precompiled headers' and try again.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top