[cfe-users] libcxx.llvm.org linux build instructions unclear
Larry Evans
cppljevans at suddenlink.net
Sun Jul 13 20:54:36 PDT 2014
On 07/10/2014 03:46 PM, Larry Evans wrote:
> On 07/10/2014 03:23 PM, Jeffrey Walton wrote:
>>> Unfortunately, when using libcxx with a hello_world.cpp, get missing
>>> files:
>>>
>>> make
>>> ls -ld /usr/local/lib/libc++*
>>> lrwxrwxrwx 1 root root 11 Jul 10 12:45 /usr/local/lib/libc++.so ->
>>> libc++.so.1
>>> lrwxrwxrwx 1 root root 13 Jul 10 12:45
>>> /usr/local/lib/libc++.so.1 ->
>>> libc++.so.1.0
>>> -rw-r--r-- 1 root root 1054759 Jul 10 11:53 /usr/local/lib/libc++.so.1.0
>>> ls -ld /usr/local/include/c++/v1/../*
>>> drwxr-xr-x 19 root root 4096 Jul 7 12:11
>>> /usr/local/include/c++/v1/../4.9.0
>>> drwxr-xr-x 5 root root 4096 Jul 10 12:45
>>> /usr/local/include/c++/v1/../v1
>>> /usr/local/bin/clang++ -std=c++11 -stdlib=libc++ -nostdinc
>>> -I/usr/local/include/c++/v1 -I/usr/local/include/c++/v1/../4.9.0
>>> -L/usr/local/lib hello_world.cpp -o hello_world.exe
>>> In file included from hello_world.cpp:1:
>>> /usr/local/include/c++/v1/../4.9.0/iostream:38:10: fatal error:
>>> 'bits/c++config.h' file not found
>>> #include <bits/c++config.h>
>>> ^
>>> 1 error generated.
>>> make: *** [run] Error 1
>>>
>>> Anyone have any ideas how to get libcxx to work on ubuntu?
>>>
>> Its a distant memory, but....
>>
>> I seem to recall I had to use -I to include the path to the correct
>> headers like <bits/c++config.h>. This was on Debian with an updated
>> Clang (I built and used 3.3 in /usr/local/bin, while Debian provided
>> 3.1, IIRC).
>>
>> Jeff
>>
> Thanks Jeff. That got me a little farther, but now missing other
> files. First had to add another -I for features.h, but now I'm
> getting compile error as well as another missing file:
>
> make
> ls -ld /usr/local/lib/libc++*
> lrwxrwxrwx 1 root root 11 Jul 10 12:45 /usr/local/lib/libc++.so ->
> libc++.so.1
> lrwxrwxrwx 1 root root 13 Jul 10 12:45 /usr/local/lib/libc++.so.1
> -> libc++.so.1.0
> -rw-r--r-- 1 root root 1054759 Jul 10 11:53 /usr/local/lib/libc++.so.1.0
> ls -ld /usr/local/include/c++/v1/../*
> drwxr-xr-x 19 root root 4096 Jul 7 12:11
> /usr/local/include/c++/v1/../4.9.0
> drwxr-xr-x 5 root root 4096 Jul 10 12:45 /usr/local/include/c++/v1/../v1
> /usr/local/bin/clang++ -std=c++11 -stdlib=libc++ -nostdinc
> -I/usr/local/include/c++/v1
> -I/usr/local/include/c++/4.9.0/x86_64-unknown-linux-gnu
> -I/usr/local/include/c++/4.9.0 -I/usr/local/include/c++/4.9.0/parallel
> -L/usr/local/lib hello_world.cpp -o hello_world.exe
> In file included from hello_world.cpp:1:
> In file included from /usr/local/include/c++/4.9.0/iostream:38:
> In file included from
> /usr/local/include/c++/4.9.0/x86_64-unknown-linux-gnu/bits/c++config.h:430:
> /usr/local/include/c++/4.9.0/x86_64-unknown-linux-gnu/bits/os_defines.h:44:19:
> error: token is not a valid binary operator in a
> preprocessor subexpression
> #if __GLIBC_PREREQ(2,15) && defined(_GNU_SOURCE)
> ~~~~~~~~~~~~~~^
> In file included from hello_world.cpp:1:
> In file included from /usr/local/include/c++/4.9.0/iostream:39:
> In file included from /usr/local/include/c++/4.9.0/ostream:38:
> In file included from /usr/local/include/c++/4.9.0/ios:38:
> In file included from /usr/local/include/c++/4.9.0/iosfwd:40:
> In file included from /usr/local/include/c++/4.9.0/bits/postypes.h:40:
> /usr/local/include/c++/4.9.0/cwchar:44:10: fatal error: 'wchar.h' file
> not found
> #include <wchar.h>
> ^
> 2 errors generated.
> make: *** [run] Error 1
>
> Compilation exited abnormally with code 2 at Thu Jul 10 15:42:43
>
> -regards,
> Larry
I cleared the build directory and started over. The difference this
time was I specified the CC= (in addition to the CXX=. IOW:
CC=clang CXX=clang++ cmake -G "Unix Makefiles"
-DLIBCXX_CXX_ABI=libstdc++
-DLIBCXX_LIBSUPCXX_INCLUDE_PATHS="/usr/local/include/c++/4.9.0/;/usr/local/include/c++/4.9.0/x86_64-unknown-linux-gnu/"
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ../..
where the last ../.. is the libcxx source.
I also had to add -Wl,-lstdc++ to the link command when
compiling&linking a hello_world.cpp program. This avoided
this link error:
/usr/local/bin/clang++ -std=c++1y -stdlib=libc++ hello_world.cpp -o
hello_world.exe
/usr/bin/ld: /tmp/hello_world-3c8536.o: undefined reference to
symbol '__cxa_free_exception@@CXXABI_1.3'
//usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols:
DSO missing from command line
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
Hope this helps someone else.
-regards,
Larry
More information about the cfe-users
mailing list