[cfe-dev] libcxx install location?

Larry Evans cppljevans at suddenlink.net
Sat Feb 5 08:37:32 PST 2011


On 02/05/11 10:26, Jean-Daniel Dupas wrote:
> 
> Le 5 févr. 2011 à 16:56, Larry Evans a écrit :
> 
>> On 02/05/11 09:09, Jean-Daniel Dupas wrote:
>>>
>>> Le 5 févr. 2011 à 15:05, Larry Evans a écrit :
>>>
>>>> On 02/05/11 07:52, Jean-Daniel Dupas wrote:
>>>>>
>>>>> Le 5 févr. 2011 à 14:26, Larry Evans a écrit :
>>>> [snip]
>>>>>> Am I missing something?
>>>>>
>>>>> I don't have access to my linux machine right now, so I cannot test,
>>>>> but I think you can link on libstdc++ to get the missing symbols
>>>>> (just adding -lstdc++ to the linker flags should be enough).
>>>>>
>>>>> It should not conflict with libc++ symbols as libc++ uses inline
>>>>> namespace, and so mangle the standard symbols differently than the
>>>>> libstdc++.
>>>>>
>>>>> This is what we use to do on OS X before we got a separate libc++abi
>>>>> library.
>>>>>
>>>>> -- Jean-Daniel
>>>>
>>>> Thanks Jean; however, I'm getting the same error:
>>>
>>> OK. In fact, you have to add this flag to the libc++ LDFLAGS (in buildit
>>> script).
>>> Make sure to also add -std=c++0x  to the cflags to enable latest clang
>>> enhancements.
>>>
>>>    EXTRA_FLAGS="-std=c++0x"
>>>    LDSHARED_FLAGS="-o libc++.so.1.0 \
>>>        -shared -nodefaultlibs -Wl,-soname,libc++.so.1 \
>>>        -lpthread -lrt -lc -lstdc++"
>>>
>>>
>>> As the library soname is libc++.so.1, you have to create a
>>> /usr/lib/libc++.so.1 symlink that point to the library. Else you will
>>> get a "library not found" runtime error.
>>>
>>> After theses changes, I was able to compile a simple hello world program.
>>>
>>> --------- hello.cpp
>>> #include <iostream>
>>>
>>> int main (int argc, char * const argv[]) {
>>>    // insert code here...
>>>    std::cout << "Hello, World!\n";
>>>    return 0;
>>> }
>>> ------------------------
>>>
>>> Unfortunalty, this simple code does not run properly. It prints "Hello
>>> World", and then a lot of garbage (and sometimes segfault too).
>>>
>>> But this may be a good base to start hacking on libc++.
>>>
>>>
>>> -- Jean-Daniel
>>
>> I really appreciate the help Jean-Daniel!
>>
>> I did make the changes you suggested to the buildit, then
>> invoked buildit, then added the symlink; however, now
>> the compiler can't find the just created libc++ :(
>>
>> /usr/lib $ sudo ln -sf
>> /home/evansl/download/llvm/svn/llvm/projects/libcxx/lib/libc++.so.1.0
>> libc++.so.1.0
> 
> should be 
> 
> cd /usr/lib
> sudo ln -sf /home/evansl/download/llvm/svn/llvm/projects/libcxx/lib/libc++.so.1.0 libc++.so
> sudo ln -sf /home/evansl/download/llvm/svn/llvm/projects/libcxx/lib/libc++.so.1.0 libc++.so.1
> 
> You need a libc++.so symlink to compile (that what the static linker expects), and a libc++.so.1 (no .0 here) symlink to run your program (that what the dynamic linker is looking for).
> 
> 
> -- Jean-Daniel
Thank you!

/usr/lib $ sudo ln -sf
/home/evansl/download/llvm/svn/llvm/projects/libcxx/lib/libc++.so.1.0
libc++.so

/usr/lib $ sudo ln -sf
/home/evansl/download/llvm/svn/llvm/projects/libcxx/lib/libc++.so.1.0
libc++.so.1

/usr/lib $ pushd
~/prog_dev/clang $ make compile
/home/evansl/download/llvm/svn/build/Debug+Asserts/bin/clang++ -c
-stdlib=libc++ move.cpp -o move.o
/home/evansl/download/llvm/svn/build/Debug+Asserts/bin/clang++ move.o
-stdlib=libc++ -lstdc++ -o move.exe
./move.exe
~/prog_dev/clang $




More information about the cfe-dev mailing list