[cfe-dev] libcxx install location?
Larry Evans
cppljevans at suddenlink.net
Sat Feb 5 07:56:42 PST 2011
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
/usr/lib $ ls -ld libc++*
lrwxrwxrwx 1 0 0 69 Feb 5 09:50
libc++.so.1.0 ->
/home/evansl/download/llvm/svn/llvm/projects/libcxx/lib/libc++.so.1.0
/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
/usr/bin/ld: cannot find -lc++
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
make: *** [compile] Error 1
~/prog_dev/clang $ pushd
/usr/lib $ pushd /home/evansl/download/llvm/svn/llvm/projects/libcxx/lib
~/download/llvm/svn/llvm/projects/libcxx/lib $ rcsdiff buildit
===================================================================
RCS file: RCS/buildit,v
retrieving revision 1.1
diff -r1.1 buildit
62a63
> EXTRA_FLAGS="-std=c++0x"
65c66
< -lpthread -lrt -lc"
---
> -lpthread -lrt -lc -lstdc++"
~/download/llvm/svn/llvm/projects/libcxx/lib $
More information about the cfe-dev
mailing list