User forums > Help

Compiling Error

(1/1)

KingerTheThird:
I'm having a problem getting a C++ file to build.  I made the source as simple as possible to try and get rid of all possibilities but I'm still having a problem.  When I go to build, the build log looks like:


--- Code: ---Project   : AI Program 1 - Slide Puzzle
Compiler  : GNU GCC Compiler (called directly)
Directory : C:\Documents and Settings\Kinger\My Documents\Code Blocks\AI\Slide Puzzle\
--------------------------------------------------------------------------------
Switching to target: default
Compiling: SlideMain.cpp
Linking console executable: AI Project 1 - Slide Puzzle.exe
C:/Program Files/CodeBlocks/bin/../lib/gcc/mingw32/3.4.4/../../../libmingw32.a(main.o):main.c:(.text+0x106): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 5 seconds)
0 errors, 0 warnings

--- End code ---

It says there are no problems, but there is no executable file in the Slide Puzzle Directory.  The .objs directory appears with the SlideMain.o file in it.  Here is the source, as short as it is:


--- Code: ---#include<iostream>
using namespace::std;

int Main()
{
  cout<<"Hello World!";
}

--- End code ---

I'm a little curious as to why it's looking for WinMain@16 at all, this is going to be a console program.  Also, I opened a Win32 template and compiled that and it went together fine and made an Executable.

sethjackson:
Go to: Project -> Properties -> Targets -> your_target_name -> Type. Set the type to console. :D

BTW

C:/Program Files/CodeBlocks/bin/../lib/gcc/mingw32/3.4.4/../../../libmingw32.a(main.o):main.c:(.text+0x106): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 5 seconds)

When you have link errors I wouldn't call that a successfull build.......

KingerTheThird:
Thanks for the help.

When I went into change the type is was already set to console.

Do I need to add the project under targets, or can I just leave it under Default?

sethjackson:
Ok. Well I should have read your post more carefully.....


--- Code: (cpp) ---...

int Main()
{
  cout<<"Hello World!";
}

--- End code ---

Should be:


--- Code: (cpp) ---...

int main()
{
  cout<<"Hello World!";
}

--- End code ---

Notice the lower-case M. ;)

KingerTheThird:
That worked, thanks.

Navigation

[0] Message Index

Go to full version