Pelles C forum

C language => Beginner questions => Topic started by: rodan07 on December 26, 2010, 11:12:05 PM

Title: problem building exe files
Post by: rodan07 on December 26, 2010, 11:12:05 PM
Hello all,

I'm new to using Pelles C, and C itself.

I'm copying some programs out of the Kernighan/Ritchie book, but I keep getting this error when trying to build an executable out of source code:

Building fahrenheit.exe.
POLINK: error: Unresolved external symbol '_WinMain@16'.
POLINK: fatal error: 1 unresolved external(s).
*** Error code: 1 ***
Done.

Does anyone know how to get around this?

Thanks,

Rodan
Title: Re: problem building exe files
Post by: CommonTater on December 27, 2010, 12:23:26 AM
You need to use

#define WIN32_DEFAULT_LIBS
#include <windows.h>

at the top of each file for a windows program.

The WIN32_DEFAULT_LIBS is optional and specific to PellesC ... what it does is tell the linker which windows libraries to include while constructing the final EXE file...

If you are going to try your hand at windows programming you will also need the Windows Software Development Kit (SDK) which give you full disclosure of all windows calls...

You can download it here...
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=6b6c21d2-2006-4afa-9702-529fa782d63b&displaylang=en

Title: Re: problem building exe files
Post by: TimoVJL on December 27, 2010, 07:51:39 AM
If your program has main-function then select from projects linker options Subsystem Type Console.