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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Beginner problem

Status
Not open for further replies.

isandir

Programmer
Jan 7, 2005
2
US
Hi,

I dont really know if this is the correct place to be posting this but i have a ver simple problem. I have a very simple hello world win32 application.

This is the code:

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int iCmdShow)
{
MessageBox(NULL, "Hello, world!", "Example", 0);
return 0;
}

The code compiles and runs in Dev C++ but fails in microsoft visual C++ with two errors.

error LNK2005: _WinMain@16 already defined in hello.obj
fatal error LNK1169: one or multiply defined symbols found

Before these two errors i was getting a error about precompiled headers but i turned them off.

Any insight would be appreciated.

Thanks
 
It's finding two WinMain's.

Do you have multiple files in your project - if so, check each for a WinMain.

Doing
[tt]Build->Clean
Build->Rebuild All[/tt]
is not a bad idea from time to time.

--
 


That was really useful, i figured out that when i
made a new project it created a .cpp and a .h file
the problem was it wasnt showing them to me. All
i saw was a project of a certain name created,
so then i was adding a new .cpp file to the project to put my code in while the other "stealth" .cpp file was already using winmain.

I was wondering if there was an easy way to view all
the files inside of a project, because when i created my helloworld project i was not notified that code was being autogenerated along with it. Thanks for the help though i got my hello world text box popping up quite nicely.

 
If you are using VC++ 6.0 look at the FileView in the Workspace window, the .cpp files are under Source Files and the .h files are under Header Files. The same is true for the Solution Explorer if you are using the .NET version.
 
> made a new project it created a .cpp and a .h file
Yeah - it's only the "blank" projects which create truly empty projects. All the others (AFAIK) create some initial program stub to get you going.



--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top