file not recognized: File format not recognized
Example:
#include <stdio.h> int main (void) { printf ("Hello World!\n"); return 0; }
If the program above is saved in a file hello without any extension then compiling it will give the error:
$ gcc -Wall hello hello: file not recognized: File format not recognized collect2: ld returned 1 exit status
The solution is to rename the file to the correct extension, in this
case hello.c.
undefined reference to `foo'
collect2: ld returned 1 exit status
Example:
int foo(void); int main (void) { foo(); return 0; }
If this program is compiled without linking to a library or object file
containing the function foo()
there will be an undefined
reference error.
/usr/lib/crt1.o(.text+0x18): undefined reference to `main'
main
. In C and C++, every program must have a
main
function (where execution starts). When compiling an
individual source file without a main
function, use the option
-c (see Creating object files from source files).