0

I am trying to compile a file in Mac OS X but keep on getting the error

Undefined symbols:
  "_main", referenced from:
      start in crt1.10.6.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

Could any one help to find out what this error means?

Mahesh
  • 34,573
  • 20
  • 89
  • 115
noddy
  • 1,010
  • 4
  • 14
  • 27

1 Answers1

4

You are missing main definition in the program which is the starting point of any executable. So, linker is complaining because it didn't find the entry point ( which is main ) for the final executable.

Undefined symbols:
"_main",

Meaning there is no _main in any of the source files compiled. ( i.e., int main(void), int main( int agrc, const char* argv[] in C, C++ )

ld: symbol(s) not found

Meaning it is a linker error. Linker binds all the object files to a single executable. At this time it checks whether there is entry point at all for the executable. It isn't in your case, so it is complaining.

Macmade
  • 52,708
  • 13
  • 106
  • 123
Mahesh
  • 34,573
  • 20
  • 89
  • 115
  • Also could you advise me how to add the glut library to my mac OSX so that i could compile glut programs directly from the terminal instead of using Xcode?? – noddy Sep 08 '11 at 14:38
  • Check this thread. http://stackoverflow.com/questions/6851557/why-wont-this-glut-program-compile-am-i-missing-libraries-or-headers – Mahesh Sep 08 '11 at 14:40
  • Well I want to compile it from the terminal in a MAC OSX itself not on a linux machine..the thread that you have mentioned talks of running it on a linux machine...?? – noddy Sep 08 '11 at 15:13
  • Since you said you need build & run the program using terminal, that would definitely work. Try it once :) – Mahesh Sep 08 '11 at 15:19
  • i got the answer ...what i was missing was the command for running it in the terminal – noddy Sep 08 '11 at 15:25
  • gcc -framework GLUT -framework OpenGL -framework Cocoa robot.c -o robot this command would help in compiling the file.. – noddy Sep 08 '11 at 15:26
  • noddy - Correct. That's how I did it on my Mac a year back. Sorry for the confusion caused :( But we can link it our selves but that is rather pointless when we have a straight forward way of doing on a Mac machine. – Mahesh Sep 08 '11 at 15:28