need help

Hi All:

I am getting the following error when I try to compile a simple program using clang

Looks like you're not including <string.h>. I don't see that this is a Clang development issue.

Sebastian

I think he meant the linker issue :slight_smile:

Wei: What system is this on? And where is crtbegin.o on your system? Can you run clang with -v to see?

-eric

Looks like you're not including <string.h>. I don't see that this is a Clang development issue.

You missed the real error, on the line below:

/usr/bin/ld: crtbegin.o: No such file: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Looks like the clang driver is not passing the correct arguments to ld.

David

I committed a patch here:

[yendi:llvm/tools/clang] echristo% svn ci
Sending lib/Driver/ToolChains.cpp
Sending lib/Frontend/InitHeaderSearch.cpp
Transmitting file data …
Committed revision 131505.

which should help you. Go ahead and rebuild top of tree again and let me know.

-eric

I dont known if the OP replied, but I'm at latest with llvm (r132323)
and clang(132321) running on Ubuntu 10.04 and am still having this
same issue:

clang++ test.o -v
clang version 3.0 (trunk 132323)
Target: i386-pc-linux-gnu
Thread model: posix
"/usr/bin/ld" -z relro --hash-style=gnu --build-id --eh-frame-hdr -m
elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o a.out
/usr/lib/../lib/crt1.o /usr/lib/../lib/crti.o crtbegin.o -L
-L/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/../../..
-L/usr/lib/ test.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
crtend.o /usr/lib/../lib/crtn.o
/usr/bin/ld: cannot find crtbegin.o: No such file or directory
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lgcc
clang: error: linker command failed with exit code 1 (use -v to see invocation)

      Andy

I dont known if the OP replied, but I'm at latest with llvm (r132323)
and clang(132321) running on Ubuntu 10.04 and am still having this
same issue:

Things have to be changed for each platform so this wouldn't matter for you. If you give me the information I asked for from the OP I can probably help.

-eric

System is ubuntu 11.04 (mistake in last post)

crtbegin.o lives in /usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/
or any of the 4.[45].x dirs as I have several version of gcc
installed.

clang++ -v output you see in the post you replied to.

    Andy

System is ubuntu 11.04 (mistake in last post)

crtbegin.o lives in /usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/
or any of the 4.[45].x dirs as I have several version of gcc
installed.

That directory looks very very odd with both an i386-linux-gnu and an
i686-linux-gnu. Is that the normal directory?

clang++ -v output you see in the post you replied to.

So there's already 11.04 support in clang for the platform. Have you
installed multiple compilers over what is normally there or moved
things around? AFAIK a generic install should work.

-eric

System is ubuntu 11.04 (mistake in last post)

crtbegin.o lives in /usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/
or any of the 4.[45].x dirs as I have several version of gcc
installed.

That directory looks very very odd with both an i386-linux-gnu and an
i686-linux-gnu. Is that the normal directory?

It does look weird, but it's where it is, and I checked to make sure
it's where the package system says they should be, and it's correct.

clang++ -v output you see in the post you replied to.

So there's already 11.04 support in clang for the platform. Have you
installed multiple compilers over what is normally there or moved
things around? AFAIK a generic install should work.

All the gcc compilers are installed via the package manager. Clang was
installed via sources.

I'm not sure what to make of it. I didn't do anything special when
configuring llvm/clang either.

System is ubuntu 11.04 (mistake in last post)

crtbegin.o lives in /usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/
or any of the 4.[45].x dirs as I have several version of gcc
installed.

That directory looks very very odd with both an i386-linux-gnu and an
i686-linux-gnu. Is that the normal directory?

It does look weird, but it's where it is, and I checked to make sure
it's where the package system says they should be, and it's correct.

Hrm. OK. The clang sources believe they know where things might be at
least for header files. I guess it's finding the headers, but just not
the crt files?

clang++ -v output you see in the post you replied to.

So there's already 11.04 support in clang for the platform. Have you
installed multiple compilers over what is normally there or moved
things around? AFAIK a generic install should work.

All the gcc compilers are installed via the package manager. Clang was
installed via sources.

I'm not sure what to make of it. I didn't do anything special when
configuring llvm/clang either.

OK :slight_smile:

-eric

System is ubuntu 11.04 (mistake in last post)

crtbegin.o lives in /usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/
or any of the 4.[45].x dirs as I have several version of gcc
installed.

That directory looks very very odd with both an i386-linux-gnu and an
i686-linux-gnu. Is that the normal directory?

It does look weird, but it's where it is, and I checked to make sure
it's where the package system says they should be, and it's correct.

Hrm. OK. The clang sources believe they know where things might be at
least for header files. I guess it's finding the headers, but just not
the crt files?

Thats what it seems to me. Is there any other information I could
provide to solve the mystery?

I can just link by hand if this is not high on the priority list, but
it seems like something that needs fixing.

clang++ -v output you see in the post you replied to.

So there's already 11.04 support in clang for the platform. Have you
installed multiple compilers over what is normally there or moved
things around? AFAIK a generic install should work.

All the gcc compilers are installed via the package manager. Clang was
installed via sources.

I'm not sure what to make of it. I didn't do anything special when
configuring llvm/clang either.

OK :slight_smile:

Should I have? I had a thought that maybe I was supposed to pass a
string at configure time, or adjust a runtime configuration file.

Is there something I should edit to provide the info to the compiler?

System is ubuntu 11.04 (mistake in last post)

crtbegin.o lives in /usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/
or any of the 4.[45].x dirs as I have several version of gcc
installed.

That directory looks very very odd with both an i386-linux-gnu and an
i686-linux-gnu. Is that the normal directory?

It does look weird, but it's where it is, and I checked to make sure
it's where the package system says they should be, and it's correct.

Hrm. OK. The clang sources believe they know where things might be at
least for header files. I guess it's finding the headers, but just not
the crt files?

Thats what it seems to me. Is there any other information I could
provide to solve the mystery?

Nope. That should do it.

I can just link by hand if this is not high on the priority list, but
it seems like something that needs fixing.

I'll try to fix it tomorrow.

Should I have? I had a thought that maybe I was supposed to pass a
string at configure time, or adjust a runtime configuration file.

Is there something I should edit to provide the info to the compiler?

In an ideal world, maybe. In actuality, no.

Thanks for the help. I'll see what I can do to get you going tomorrow :slight_smile:

-eric

Looking into this a bit more it's odd that your system uses i386-linux-gnu when
it looks like the rest of the ubuntu world uses i486-linux-gnu for the first
part of that triple? Also on every other system I've seen those two match.

I'm still thinking about how to solve the latter problem.

-eric

I've verified that it's only in that one place, and found a link
suggesting others having the same issue:

   http://lists.cs.uiuc.edu/pipermail/llvmbugs/2011-April/017914.html

and a relevant package list:

   Ubuntu – Error

    Andy