在Ubuntu中使用clang ++编译libc ++ [英] compiling libc++ with clang++ in Ubuntu

查看:624
本文介绍了在Ubuntu中使用clang ++编译libc ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的操作系统是Ubuntu-11.04
我按照用户手册成功编译了llvm和clang。
然后我试图用clang ++编译libcxx,
i通过读取以下

来修改$ LIBCXX_DIR / lib / buildit.sh

http://lists.cs.uiuc.edu/pipermail/cfe -dev / 2011-February / 013228.html



修改的文件$ LIBCXX_DIR / lib / buildit在错误消息后粘贴。



修改buildit.sh得到以下错误。看来clang ++不能
编译头文件'string'成功。
这是完整的编译报告:

  vmplanet @ kubuntu-vm:〜/ usr / libcxx / lib $。 / buildit 
clang ++ -c -g -Os -fPIC -std = c ++ 0x -nostdinc ++ -I ../ include
../src/algorithm.cpp
clang ++ -c - g -Os -fPIC -std = c ++ 0x -nostdinc ++ -I ../ include ../src/bind.cpp
clang ++ -c -g -Os -fPIC -std = c ++ 0x -nostdinc ++ -I ../ include ../src/chrono.cpp
clang ++ -c -g -Os -fPIC -std = c ++ 0x -nostdinc ++ -I ../ include
../src /condition_variable.cpp
clang ++ -c -g -Os -fPIC -std = c ++ 0x -nostdinc ++ -I ../ include
../src/exception.cpp
.. /src/exception.cpp:85:6:warning:#warning uncaught_exception not yet
实现[-W#warnings]
#warning uncaught_exception尚未实现
^
.. /src/exception.cpp:119:6:warning:#warning exception_ptr尚未实现
[-W#warnings]
#warning exception_ptr尚未实现
^
。 /src/exception.cpp:130:6:warning:#warning exception_ptr尚未实现
[-W#warnings]
#warning exception_ptr尚未实现
^
.. /src/exception.cpp:146:6:warning:#warning exception_ptr尚未实现
[-W#warnings]
#warning exception_ptr尚未实现
^
.. /src/exception.cpp:181:6:warning:#warning exception_ptr尚未实现
[-W#warnings]
#warning exception_ptr尚未实现
^
.. /src/exception.cpp:193:6:warning:#warning exception_ptr尚未实现
[-W#warnings]
#warning exception_ptr尚未实现
^
6个警告生成。
clang ++ -c -g -Os -fPIC -std = c ++ 0x -nostdinc ++ -I ../ include ../src/future.cpp
clang ++ -c -g -Os -fPIC - std = c ++ 0x -nostdinc ++ -I ../ include ../src/hash.cpp
clang ++ -c -g -Os -fPIC -std = c ++ 0x -nostdinc ++ -I ../ include ../src/ios.cpp
clang ++ -c -g -Os -fPIC -std = c ++ 0x -nostdinc ++ -I ../ include ../src/iostream.cpp
clang ++ - c -g -Os -fPIC -std = c ++ 0x -nostdinc ++ -I ../ include ../src/locale.cpp
在从../src/locale.cpp:10中包含的文件中:
../include/string:2122:10:错误:重载解决选择删除的操作符
'='
__r_ = _STD :: move(__ str .__ r_);
~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~
../include/string:2133:5:注意:在实例化的成员函数
'std :: __ 1 :: basic_string< char,std :: __ 1 :: char_traits< char> ;,
std :: __ 1 :: allocator< char> > :: __ move_assign'
请求此处
__move_assign(__ str,integral_constant< bool,
^
../src/locale.cpp:4772:10:note:in instantiation的成员函数
'std :: __ 1 :: basic_string< char,std :: __ 1 :: char_traits< char> ;,
std :: __ 1 :: allocator< char>
请求这里
__c_ = __analyze('c',ct);
^
../include/memory:2050:7:注意:候选函数b $ b赋值运算符)已被明确删除
class __compressed_pa​​ir
^
在从../src/locale.cpp:10中包含的文件中:
../include/string :2122:10:错误:重载分辨率选择删除的操作符
'='
__r_ = _STD :: move(__ str .__ r_);
~~~~ ^ ~~~~~~ ~~~~~~~~~
../include/string:2133:5:注意:在实例化成员函数
'std :: __ 1 :: basic_string< ; wchar_t,std :: __ 1 :: char_traits< wchar_t>,
std :: __ 1 :: allocator< wchar_t>
> :: __ move_assign'请求这里
__move_assign(__ str,integral_constant< bool,
^
../include/locale:2796:15:note:in memberiation of member function
'std :: __ 1 :: basic_string< wchar_t,std :: __ 1 :: char_traits< wchar_t>,
std :: __ 1 :: allocator< wchar_t>> :: operator ='
请求这里
__nsn = __mp.negative_sign();
^
../include/memory:2050:7:注意:候选函数(隐式复制
赋值操作符)已被明确删除
class __compressed_pa​​ir
^
产生2个错误。

// buildit.sh

 #!/ bin / sh 

#在
#运行此脚本之前,将$ TRIPLE环境变量设置为系统的三元组。如果设置$ CXX,那么将用于编译
#库,否则我们将使用clang ++。

set -e

if [`basename $(pwd)`!=lib]
then
echo当前目录be lib
exit 1
fi

CXX = clang ++
CC = clang

如果[-z $ RC_ProjectSourceVersion]
then
RC_ProjectSourceVersion = 1
fi

EXTRA_FLAGS = - std = c ++ 0x
EXTRA_FLAGS = - std = c ++ 0x
LDSHARED_FLAGS = - o libc ++。so.1.0 \
-shared -nodefaultlibs -Wl,-soname,libc ++。so.1 \
-lpthread -lrt -lc -lstdc ++

RC_CFLAGS = - fPIC
SOEXT = so

for FILE in ../src/*.cpp; do
echo $ CXX -c -g -Os $ RC_CFLAGS $ EXTRA_FLAGS -nostdinc ++ -I ../ include $ FILE
$ CXX -c -g -Os $ RC_CFLAGS $ EXTRA_FLAGS -nostdinc ++ -I .. / include $ FILE
done

$ CC * .o $ RC_CFLAGS $ LDSHARED_FLAGS $ EXTRA_FLAGS

#libtool -static -o libc ++。a * .o

if [-z $ RC_XBS]
then
rm * .o
fi


解决方案

好了,错误消息解释了自己,看Howard Hinnant对我的问题的回答: std :: async在clang 3.0 + libc ++不工作?
我猜这是相同的地方。 / p>

My OS is Ubuntu-11.04 i compiled llvm with clang as per the user manual successfully. then i tried to compile libcxx with clang++, i made modifications to the $LIBCXX_DIR/lib/buildit.sh by reading the following

http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-February/013228.html

The modified file $LIBCXX_DIR/lib/buildit is pasted after the error message.

with the modified buildit.sh i get following errors. It seems clang++ is unable to compile the header file 'string' successfully. Here is the complete compilation report:

vmplanet@kubuntu-vm:~/usr/libcxx/lib$ ./buildit 
clang++ -c -g -Os -fPIC -std=c++0x -nostdinc++ -I../include
../src/algorithm.cpp
clang++ -c -g -Os -fPIC -std=c++0x -nostdinc++ -I../include ../src/bind.cpp
clang++ -c -g -Os -fPIC -std=c++0x -nostdinc++ -I../include ../src/chrono.cpp
clang++ -c -g -Os -fPIC -std=c++0x -nostdinc++ -I../include
../src/condition_variable.cpp
clang++ -c -g -Os -fPIC -std=c++0x -nostdinc++ -I../include
../src/exception.cpp
../src/exception.cpp:85:6: warning: #warning uncaught_exception not yet
implemented [-W#warnings]
    #warning uncaught_exception not yet implemented
     ^
../src/exception.cpp:119:6: warning: #warning exception_ptr not yet implemented
[-W#warnings]                                                                   
    #warning exception_ptr not yet implemented
     ^
../src/exception.cpp:130:6: warning: #warning exception_ptr not yet implemented
[-W#warnings]                                                                   
    #warning exception_ptr not yet implemented
     ^
../src/exception.cpp:146:6: warning: #warning exception_ptr not yet implemented
[-W#warnings]                                                                   
    #warning exception_ptr not yet implemented
     ^
../src/exception.cpp:181:6: warning: #warning exception_ptr not yet implemented
[-W#warnings]                                                                   
    #warning exception_ptr not yet implemented
     ^
../src/exception.cpp:193:6: warning: #warning exception_ptr not yet implemented
[-W#warnings]                                                                   
    #warning exception_ptr not yet implemented
     ^
6 warnings generated.                                                           
clang++ -c -g -Os -fPIC -std=c++0x -nostdinc++ -I../include ../src/future.cpp
clang++ -c -g -Os -fPIC -std=c++0x -nostdinc++ -I../include ../src/hash.cpp
clang++ -c -g -Os -fPIC -std=c++0x -nostdinc++ -I../include ../src/ios.cpp
clang++ -c -g -Os -fPIC -std=c++0x -nostdinc++ -I../include ../src/iostream.cpp
clang++ -c -g -Os -fPIC -std=c++0x -nostdinc++ -I../include ../src/locale.cpp
In file included from ../src/locale.cpp:10:
../include/string:2122:10: error: overload resolution selected deleted operator
'='
    __r_ = _STD::move(__str.__r_);
    ~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
../include/string:2133:5: note: in instantiation of member function
'std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::__move_assign'      
      requested here
    __move_assign(__str, integral_constant<bool,
    ^
../src/locale.cpp:4772:10: note: in instantiation of member function
'std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::operator='         
      requested here
    __c_ = __analyze('c', ct);
         ^
../include/memory:2050:7: note: candidate function (the implicit copy
assignment operator) has been explicitly deleted                                
class __compressed_pair
      ^
In file included from ../src/locale.cpp:10:                                     
../include/string:2122:10: error: overload resolution selected deleted operator
'='
    __r_ = _STD::move(__str.__r_);
    ~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
../include/string:2133:5: note: in instantiation of member function
'std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>,
std::__1::allocator<wchar_t>               
      >::__move_assign' requested here
    __move_assign(__str, integral_constant<bool,
    ^
../include/locale:2796:15: note: in instantiation of member function
'std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>,
std::__1::allocator<wchar_t> >::operator='
      requested here
        __nsn = __mp.negative_sign();
              ^
../include/memory:2050:7: note: candidate function (the implicit copy
assignment operator) has been explicitly deleted                                
class __compressed_pair
      ^
2 errors generated.

//buildit.sh

#! /bin/sh
#
# Set the $TRIPLE environment variable to your system's triple before
# running this script.  If you set $CXX, that will be used to compile
# the library.  Otherwise we'll use clang++.

set -e

if [ `basename $(pwd)` != "lib" ]
then
  echo "current directory must be lib"
  exit 1
fi

CXX=clang++
CC=clang

if [ -z $RC_ProjectSourceVersion ]
then
  RC_ProjectSourceVersion=1
fi

EXTRA_FLAGS="-std=c++0x "
    EXTRA_FLAGS="-std=c++0x"
    LDSHARED_FLAGS="-o libc++.so.1.0 \
      -shared -nodefaultlibs -Wl,-soname,libc++.so.1 \
      -lpthread -lrt -lc -lstdc++"

    RC_CFLAGS="-fPIC"
    SOEXT=so

for FILE in ../src/*.cpp; do
  echo $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -nostdinc++ -I../include $FILE
  $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -nostdinc++ -I../include $FILE
done

$CC *.o $RC_CFLAGS $LDSHARED_FLAGS $EXTRA_FLAGS

#libtool -static -o libc++.a *.o

if [ -z $RC_XBS ]
then
    rm *.o
fi

解决方案

Well, the error message explains itself, see Howard Hinnant's answer to my question: std::async in clang 3.0 + libc++ doesn't work? I guess that's the same place.

这篇关于在Ubuntu中使用clang ++编译libc ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆