Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/163.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 对libc+中istringstream析构函数中运算符delete的未定义引用+;_C++_Gcc_Clang_Clang++ - Fatal编程技术网

C++ 对libc+中istringstream析构函数中运算符delete的未定义引用+;

C++ 对libc+中istringstream析构函数中运算符delete的未定义引用+;,c++,gcc,clang,clang++,C++,Gcc,Clang,Clang++,我试图通过两种方式从主干(~3.7)构建clang++:通过gcc(4.8)和(旧的)clang++(来自数据包管理器的3.4和3.5)。这两个步骤包括相同的步骤: export CC=clang export CXX=clang++ export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:$HOME/llvm/projects/libcxxabi/include" sudo apt-get install git cd git clone --sing

我试图通过两种方式从主干(~3.7)构建
clang++
:通过
gcc
(4.8)和(旧的)
clang++
(来自数据包管理器的3.4和3.5)。这两个步骤包括相同的步骤:

export CC=clang
export CXX=clang++
export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:$HOME/llvm/projects/libcxxabi/include"

sudo apt-get install git

cd
git clone --single-branch --branch master --depth=1 http://llvm.org/git/llvm
cd llvm/projects/
git clone --single-branch --branch master --depth=1 http://llvm.org/git/libcxxabi
git clone --single-branch --branch master --depth=1 http://llvm.org/git/libcxx
git clone --single-branch --branch master --depth=1 http://llvm.org/git/compiler-rt
cd ../tools
git clone --single-branch --branch master --depth=1 http://llvm.org/git/clang
git clone --single-branch --branch master --depth=1 http://llvm.org/git/clang-tools-extra extra
git clone --single-branch --branch master --depth=1 http://llvm.org/git/lld
git clone --single-branch --branch master --depth=1 http://llvm.org/git/lldb
git clone --single-branch --branch master --depth=1 http://llvm.org/git/polly

sudo apt-get install python-dev libedit-dev libncurses-dev swig libgmp-dev libgmp3-dev dh-autoreconf libunwind8 libunwind8-dev cmake

cd
cd llvm/tools/polly/utils
mkdir -p ~/build-cloog
bash checkout_cloog.sh ~/build-cloog
mkdir -p ~/build-isl
bash checkout_isl.sh ~/build-isl
cd ~/build-isl/
./configure
make
sudo make install
cd ~/build-cloog/
./configure --with-isl=system
make
sudo make install

cd
mkdir build-llvm
cd build-llvm
bash ../llvm/configure --enable-optimized --disable-assertions --enable-libcpp --enable-jit --enable-targets=x86,x86_64 --enable-polly --enable-cxx1y --with-gmp=/usr/local --with-isl=/usr/local --with-cloog=/usr/local --with-binutils-include=/usr/include
make -j`nproc`
sudo make install
对于
CC=clang
CXX=clang++
我在链接包含
std::istringstream
实例化的简单示例时出错:

#include <sstream>

#include <cstdlib>

int
main()
{
        std::istringstream iss("1.1");
        double x;
        iss >> x;
        return EXIT_SUCCESS;
}
#包括
#包括
int
main()
{
标准:istringstream iss(“1.1”);
双x;
iss>>x;
返回退出成功;
}
错误:

user@ubuntu:~$ clang++ -stdlib=libc++ -std=gnu++1z -Ofast -march=native test.cpp -o /tmp/test
/tmp/test-785a74.o: In function `std::__1::basic_istringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_istringstream()':
test.cpp:(.text._ZNSt3__119basic_istringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEED0Ev[_ZNSt3__119basic_istringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEED0Ev]+0x5b): undefined reference to `operator delete(void*, unsigned long)'
/tmp/test-785a74.o: In function `virtual thunk to std::__1::basic_istringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_istringstream()':
test.cpp:(.text._ZTv0_n24_NSt3__119basic_istringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEED0Ev[_ZTv0_n24_NSt3__119basic_istringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEED0Ev]+0x69): undefined reference to `operator delete(void*, unsigned long)'
/tmp/test-785a74.o: In function `std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_stringbuf()':
test.cpp:(.text._ZNSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEED0Ev[_ZNSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEED0Ev]+0x26): undefined reference to `operator delete(void*, unsigned long)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
user@ubuntu:~$clang++-stdlib=libc++-std=gnu++1z-Ofast-march=native test.cpp-o/tmp/test
/tmp/test-785a74.o:在函数“std::uu 1::basic_istringstream::~basic_istringstream()”中:
test.cpp:(.text.ZNSt3_u119; basic_119;istringstreamIcNS_11char_9;traitsciens_9allocatorIcEEED0Ev[ZNSt3_119;basic_119;istringstreamIcNS_9alloctoriceeed0ev]+0x5b):对“运算符删除(无效*,无符号长)”的未定义引用
/tmp/test-785a74.o:在函数“虚拟thunk to std::_1::basic_istringstream::~basic_istringstream()”中:
test.cpp:(.text.ZTv0_n24_NSt3_u119;basic_11;istringstreamIcNS_11;traitsciens_9allocatorIcEEED0Ev)[uztv0_n24_119;NSt3_11;basic_11;istringstreamicens allocatoriceeed0ev]+0x69]:对“操作符delete(void*,unsigned long)”的未定义引用
/tmp/test-785a74.o:在函数“std::uu 1::basic_stringbuf::~basic_stringbuf()”中:
test.cpp:(.text._ZNSt3_s u stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEED0Ev[_ZNSt3_s u basic_stringbufIcNS_11char_9allocatorIcEEED0Ev]+0x26):对“运算符删除(无效*,无符号长)”的未定义引用
叮当声:错误:链接器命令失败,退出代码为1(使用-v查看调用)
但如果
CC=gcc
CXX=g++
,则不会发生错误。在这两种情况下,链接器都是来自GNU Binutils的
ld

例如,
#include
中的对象不存在此类问题


错误的原因是什么?我可以在不重建整个
clang/llvm
项目树的情况下修复它吗?

最近clangtrunk发生了变化。编译器不再发出大小运算符delete的弱定义(请参阅)。无论如何发出定义的标志(
-fdef-sized delete
)稍后在中重命名


您必须使用
-fdefine size deallocation
标志编译程序,以便clang发出大小运算符delete。这将修复链接错误。

如何编译(链接!)例如?@KarolyHorvath我键入命令
clang++-stdlib=libc++-std=gnu++1z-Ofast-march=native test.cpp-o/tmp/test
std::ifstream
,这与来自数据包管理器的clang 3.7 trunk+libc++在Ubuntu14.10上运行的问题完全相同。您确定clang包含libc++头文件而不是libstdc++头文件吗?用-VC++检查->代码> /Ur/Ic/C++/V1< /C> > @托马斯My < C> Cuang< <代码>给出<代码> /Urr/Prase/Bi/..…/Cyp+/V1< /C> >,当代码>回声“包含”CLAN++-STDLIB=LBC++-STD= GNU+1Z-WP,-V-XC++ C++ -FScript只< < /C> >类型化。你的意思是说,Ubuntu 14.10已经提供了
clangv3.7
,还是说:你通过packetmanager中的
clang3.7
从trunk构建了
clang3.7
,它运行得很好?呃,我实际上也在用gcc libstdc++4.9实现这一点。我真的希望他们能够恢复这一更改,或者至少将
-fdef-sized delete
设置为默认设置。否则,任何使用不太新的libc++/libstdc++的人都会遇到链接器错误…谢谢。这是不是
libc++
库设计的一个缺陷?@Orient:也许使用最新的
libc++
来消除链接器错误,而无需
-fdef大小的删除
。请参阅:。但是,这完全打破了<代码> LBSTDC++< /COD>标志刚刚被重命名:CLANC++状态页面也有一个简短的解释: