clang cannot find standard template library

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

clang cannot find standard template library

Pål Dahle
Hi.

Looking for an alternative to g++, I have stumbled across
clang. And, impressively, clang has managed to compile my
C++ code consisting of some 80 000 lines of code.

However, when it comes to linking, things stop. It seems
that clang does not find the standard template library.

As a matter of fact, even the trivial

#include <iostream>
int main () { std::cout << "Hello world." << std::endl; }

ends it's compilation with the following error message:

nebuchadnezzar:/opt/project/Cohiba/trunk/cohiba/tmp$ clang test.cpp
/tmp/cc-jpZ3sj.o: In function `__cxx_global_var_init':
test.cpp:(.text+0x18): undefined reference to `std::ios_base::Init::Init()'
test.cpp:(.text+0x20): undefined reference to `std::ios_base::Init::~Init()'
/tmp/cc-jpZ3sj.o: In function `main':
test.cpp:(.text+0x63): undefined reference to `std::cout'

[snip]

Can anyone give me a hint where to look? I have tried
the manual pages, but that didn't bring me any further.

By the way, I'm using the clang provided bu Ubuntu 10.04

Best regards
Pål


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang cannot find standard template library

bruce.r.stephens
Pål Dahle <[hidden email]> writes:

[...]

> nebuchadnezzar:/opt/project/Cohiba/trunk/cohiba/tmp$ clang test.cpp

Try

        clang++ test.cpp

[...]


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang cannot find standard template library

Jean-Daniel Dupas-2
In reply to this post by Pål Dahle

Le 15 juin 2010 à 16:06, Pål Dahle a écrit :

> Hi.
>
> Looking for an alternative to g++, I have stumbled across
> clang. And, impressively, clang has managed to compile my
> C++ code consisting of some 80 000 lines of code.
>
> However, when it comes to linking, things stop. It seems
> that clang does not find the standard template library.
>
> As a matter of fact, even the trivial
>
> #include <iostream>
> int main () { std::cout << "Hello world." << std::endl; }
>
> ends it's compilation with the following error message:
>
> nebuchadnezzar:/opt/project/Cohiba/trunk/cohiba/tmp$ clang test.cpp
> /tmp/cc-jpZ3sj.o: In function `__cxx_global_var_init':
> test.cpp:(.text+0x18): undefined reference to `std::ios_base::Init::Init()'
> test.cpp:(.text+0x20): undefined reference to `std::ios_base::Init::~Init()'
> /tmp/cc-jpZ3sj.o: In function `main':
> test.cpp:(.text+0x63): undefined reference to `std::cout'
>
> [snip]
>
> Can anyone give me a hint where to look? I have tried
> the manual pages, but that didn't bring me any further.
>
> By the way, I'm using the clang provided bu Ubuntu 10.04
>
> Best regards
> Pål

Use clang++ instead of clang (although this is a symlink on clang, the driver detect that it was invoked using a command containing ++ and switch to c++ mode).


-- Jean-Daniel





_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang cannot find standard template library

Pål Dahle
In reply to this post by bruce.r.stephens
On 06/15/2010 05:24 PM, Bruce Stephens wrote:

> Pål Dahle<[hidden email]>  writes:
>
> [...]
>
>> nebuchadnezzar:/opt/project/Cohiba/trunk/cohiba/tmp$ clang test.cpp
>
> Try
>
> clang++ test.cpp
>
> [...]

Thanks for your reply. Unfortunately this didn't help.

nebuchadnezzar:~$ clang++
clang++: command not found
nebuchadnezzar:~$ apt-cache search clang++
clang - Low-Level Virtual Machine (LLVM), C language family frontend


Anyway, I found a solution online

clang -emit-llvm -c file.c && llvm-ld file.o

So I am supposed to use llvm-ld for linking and not clang.

Thanks again
Pål


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang cannot find standard template library

Eric Christopher-2

On Jun 15, 2010, at 1:47 PM, Pål Dahle wrote:

> On 06/15/2010 05:24 PM, Bruce Stephens wrote:
>> Pål Dahle<[hidden email]>  writes:
>>
>> [...]
>>
>>> nebuchadnezzar:/opt/project/Cohiba/trunk/cohiba/tmp$ clang test.cpp
>>
>> Try
>>
>> clang++ test.cpp
>>
>> [...]
>
> Thanks for your reply. Unfortunately this didn't help.
>
> nebuchadnezzar:~$ clang++
> clang++: command not found
> nebuchadnezzar:~$ apt-cache search clang++
> clang - Low-Level Virtual Machine (LLVM), C language family frontend
>
>
> Anyway, I found a solution online
>
> clang -emit-llvm -c file.c && llvm-ld file.o
>
> So I am supposed to use llvm-ld for linking and not clang.

Uh no.  You really want clang++.  I don't know what's wrong with your
package, but if you download and compile the sources from llvm.org
you'll have a clang++.

-eric
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang cannot find standard template library

bruce.r.stephens
In reply to this post by Pål Dahle
Pål Dahle <[hidden email]> writes:

[...]

> Thanks for your reply. Unfortunately this didn't help.
>
> nebuchadnezzar:~$ clang++
> clang++: command not found
> nebuchadnezzar:~$ apt-cache search clang++
> clang - Low-Level Virtual Machine (LLVM), C language family frontend

It appears that things have changed since the Debian package was
produced, yes.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang cannot find standard template library

Cornelius-2
Am 15.06.2010 23:11, schrieb [hidden email]:

> Pål Dahle<[hidden email]>  writes:
>
> [...]
>
>> Thanks for your reply. Unfortunately this didn't help.
>>
>> nebuchadnezzar:~$ clang++
>> clang++: command not found
>> nebuchadnezzar:~$ apt-cache search clang++
>> clang - Low-Level Virtual Machine (LLVM), C language family frontend
>
> It appears that things have changed since the Debian package was
> produced, yes.
>
As far as I know, Ubuntu removed the clang++ symlink (for whatever
reason, maybe because clang++ was still in alpha that time). You just
need to create a symlink called clang++ to the clang executable in your
path to get clang++, though.
Cornelius
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang cannot find standard template library

Pål Dahle
On 06/15/2010 11:25 PM, Cornelius wrote:

> Am 15.06.2010 23:11, schrieb [hidden email]:
>> Pål Dahle<[hidden email]>   writes:
>>
>> [...]
>>
>>> Thanks for your reply. Unfortunately this didn't help.
>>>
>>> nebuchadnezzar:~$ clang++
>>> clang++: command not found
>>> nebuchadnezzar:~$ apt-cache search clang++
>>> clang - Low-Level Virtual Machine (LLVM), C language family frontend
>>
>> It appears that things have changed since the Debian package was
>> produced, yes.
>>
> As far as I know, Ubuntu removed the clang++ symlink (for whatever
> reason, maybe because clang++ was still in alpha that time). You just
> need to create a symlink called clang++ to the clang executable in your
> path to get clang++, though.
> Cornelius

Creating the symlink made the 'hello world' code both compile and
run. My real code also seemed to be linked nicely, but the invokation
endeed with a:

nebuchadnezzar:$ ./cohiba
unexpected reloc type in static binarySegmentation fault

A quoted google search for this error message gives a total of
one hits. I guess this is it...

Thanks for all help
Pål



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang cannot find standard template library

bruce.r.stephens
Pål Dahle <[hidden email]> writes:

[...]

> nebuchadnezzar:$ ./cohiba
> unexpected reloc type in static binarySegmentation fault
>
> A quoted google search for this error message gives a total of
> one hits. I guess this is it...

C++ support has really improved a lot (IME) in the last couple of
weeks.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev