You are not logged in.
Pages: 1
When I try to compile my C programs, it gives me this bizarre error:
/usr/lib64/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib64/crt1.o(.text+0x20): error: undefined reference to 'main'
clang: error: linker command failed with exit code 1 (use -v to see invocation)How can I fix this? I've tried setting the env variable CPATH="/usr/local/include", but it didn't change anything. Both gcc and clang give me this error.
Offline
Does the same code work when compiled with GCC?
EDIT: I'm a blind idiot xD
Anyway, could you provide more info? Like the whole command you are using, a code if you can, etc?
Last edited by kaszak696 (2013-09-28 18:58:46)
'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard
Offline
Does the same code work when compiled with GCC?
Both gcc and clang give me this error.
☑ CPU: Single core Intel Pentium M (-UP-) clocked at 1733.000 Mhz
☑ MEM: 490.1 MB
☑ HDD: 40.1 GB
Offline
It's pretty easy to replicate this error.
$ touch foo.c
$ clang foo.c
/usr/lib64/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib64/crt1.o(.text+0x20): error: undefined reference to 'main'
clang: error: linker command failed with exit code 1 (use -v to see invocation)Your program is not a program without a function called "main" somewhere.
Offline
Ohh, of course, that makes sense. I was trying to test if a function I wrote was corret, handn't put in a main yet. Thanks! Why does it say the error is in that obscure file though?
Offline
The main function ain't gonna suck itself must be called by something. The filename (ctrl = control) suggests that it is responsible for invoking the main function. When it tries to do so, it can't find it and throws an error.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Pages: 1