You are not logged in.

#1 2013-09-28 18:33:50

spencerjp
Member
Registered: 2013-09-27
Posts: 12

C Library is broken

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

#2 2013-09-28 18:50:07

kaszak696
Member
Registered: 2009-05-26
Posts: 543

Re: C Library is broken

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

#3 2013-09-28 18:56:52

XURL
Member
Registered: 2013-09-26
Posts: 24

Re: C Library is broken

kaszak696 wrote:

Does the same code work when compiled with GCC?

spencerjp wrote:

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

#4 2013-09-28 19:12:19

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: C Library is broken

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

#5 2013-09-29 00:12:01

spencerjp
Member
Registered: 2013-09-27
Posts: 12

Re: C Library is broken

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

#6 2013-09-29 00:20:51

Xyne
Forum Fellow
Registered: 2008-08-03
Posts: 6,965
Website

Re: C Library is broken

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

Board footer

Powered by FluxBB