NO

Author Topic: Building Object Error  (Read 1881 times)

AMD

  • Guest
Building Object Error
« on: October 02, 2011, 12:31:31 pm »
Please help i am trying to test this program after comiled it successfully.

here is my code:

#include <stdio.h>

int radius, area;

main()
 {
   printf( "Enter radius (i.e. 10): " );
   scanf ( "%d", &radius );
   area = (int) (3.14159 * radius * radius);
   printf( "\n\nArea = %d\n", area );
   return 0;
}

During compiling i get the following error:

Building QTwo.obj.
C:\Users\AMD\Documents\Road to Lite Hacker\C Language\Day 1\Exercises\Q2\QTwo.c(5): warning #2099: Missing type specifier; assuming 'int'.
Done.

When i try to build .exe file i receive the following error:

Building Q2.exe.
POLINK: error: Unresolved external symbol 'WinMain'.
POLINK: fatal error: 1 unresolved external(s).
*** Error code: 1 ***
Done.

i have no idea where this error is coming from.  any help is really appriciated here.

Thank you in advance

Offline Vortex

  • Member
  • *
  • Posts: 529
    • http://www.vortex.masmcode.com
Re: Building Object Error
« Reply #1 on: October 02, 2011, 12:40:14 pm »
Hi AMD,

Welcome to the forum.

The type specifier for the main function is missing.

Add int to line 5 :

Code: [Select]
int main()
Code: [Select]
POLINK: error: Unresolved external symbol 'WinMain'.
Are you sure that your project is configured to be built as console application? It looks like that you are trying to make a GUI application.
« Last Edit: October 02, 2011, 12:42:50 pm by Vortex »
Code it... That's all...

AMD

  • Guest
Re: Building Object Error
« Reply #2 on: October 02, 2011, 01:08:32 pm »
Thank you Vortex

for your magic answer.

It worked after adding the int in from of Main()

and you were right to guess i wasn't choosing consile but now i corrected it and everything worked fine.

Thank you again

CommonTater

  • Guest
Re: Building Object Error
« Reply #3 on: October 03, 2011, 12:52:15 am »
@amd ... Pelles C comes with a truly excellent help file.  You may want to spend just a few minutes looking around in it.  There's a ton of helpful hints and even a "your first program" tutorial in there, to get you started.  Also be sure to look around in the IDE... click on stuff, right click on stuff... you'll find a lot of really helpful stuff that way...

On the main() thing...  There are 2 generally preferred forms for the main function...
Code: [Select]
int main (void)
  {
     // your code here
     return 0;
}
for when you are not using command line arguments, and...
Code: [Select]
int main (int argc, char *argv[])
   {
      // your code here
      return 0;
}
when you want to read in data from the command line.