I have written a c code file called \"utilfunc.c\" this code contains my functions that I will use through my code.
Now when I am compiling my \"utilfunc.c\" file an
This was not the issue for the original poster, but here is an unusual cause for the same error message: option with missing path.
gcc -I../include -O -I. -g -O2 -DNDEBUG -O3 -fPIC -I -c graph.c -o graph.o
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/crt1.o: In function `_start':
/home/abuild/rpmbuild/BUILD/glibc-2.19/csu/../sysdeps/x86_64/start.S:118: undefined reference to `main'
collect2: error: ld returned 1 exit status
Notice the spurious -I
before -c graph.c
. Without it it compiles just fine
gcc -I../include -O -I. -g -O2 -DNDEBUG -O3 -fPIC -c graph.c -o graph.o
The problem is that the path is missing (-I
).
Adding the cwd as a path (-I.
) works fine for instance
gcc -I../include -O -I. -g -O2 -DNDEBUG -O3 -fPIC -I. -c graph.c -o graph.o
Any missing path after any command can yield this error; for instance with -L
.
gcc -I../include -O -I. -g -O2 -DNDEBUG -O3 -fPIC -L -c graph.c -o graph.o
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/crt1.o: In function `_start':
/home/abuild/rpmbuild/BUILD/glibc-2.19/csu/../sysdeps/x86_64/start.S:118: undefined reference to `main'
collect2: error: ld returned 1 exit status