GCC 4.3.4和CLANG 3.5兼容性

时间:2014-02-27 08:48:45

标签: gcc c++11 clang

我正在构建基于C ++ 11的项目,所以它至少需要GCC 4.7.2,它没有安装在我的平台上(我没有权限升级它上面的软件)。所以另一种选择是使用Clang构建项目,我下载并构建了CLang 3.5。在平台上预装了GCC 4.3.4。

当我编译代码时,我遇到了很多错误:

[ 88%] Building CXX object system/CMakeFiles/Grappa.dir/tasks/TaskingScheduler.cpp.o
cd /home/frolo/grappa/build/Make+Release/system && /home/frolo/llvm/build/Debug+Asserts/bin/clang++   -DENABLE_RDMA_AGGREGATOR -DGASNET_CONDUIT_IBV -DGASNET_IBV -DGASNET_SEQ -DSHMMAX=1844674407
3709551615 -std=c++11 -Winline -Wno-inline -mno-red-zone -O3 -g -I/home/frolo/grappa/build/Make+Release/third-party/include -I/home/frolo/grappa/build/Make+Release/third-party/include/ibv-condu
it -I/usr/mpi/gcc/openmpi-1.6.4/include -I/home/frolo/grappa/system -I/home/frolo/grappa/system/tasks    -o CMakeFiles/Grappa.dir/tasks/TaskingScheduler.cpp.o -c /home/frolo/grappa/system/tasks
/TaskingScheduler.cpp
In file included from /home/frolo/grappa/system/Barrier.cpp:24:
In file included from /home/frolo/grappa/system/Barrier.hpp:26:
In file included from /home/frolo/grappa/system/ConditionVariable.hpp:27:
In file included from /home/frolo/grappa/system/Message.hpp:27:
In file included from /home/frolo/grappa/system/MessageBase.hpp:33:
In file included from /home/frolo/grappa/system/ConditionVariableLocal.hpp:27:
/home/frolo/grappa/system/tasks/TaskingScheduler.hpp:178:25: error: no matching constructor for initialization of 'std::ofstream' (aka 'basic_ofstream<char>')
          std::ofstream f(FLAGS_stats_blob_filename);
                        ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../include/c++/4.3/fstream:571:7: note: candidate constructor not viable: no known conversion from '::fLS::clstring' (aka 'basic_string<char>') to 
'const char *' for 1st argument
      basic_ofstream(const char* __s,
      ^
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../include/c++/4.3/bits/fstream.tcc:916:25: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from '::fLS
::clstring' (aka 'basic_string<char>') to 'const std::basic_ofstream<char>' for 1st argument
  extern template class basic_ofstream<char>;
                        ^
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../include/c++/4.3/fstream:556:7: note: candidate constructor not viable: requires 0 arguments, but 1 was provided
      basic_ofstream(): __ostream_type(), _M_filebuf()
      ^
In file included from /home/frolo/grappa/system/IncoherentAcquirer.cpp:24:
In file included from /home/frolo/grappa/system/IncoherentAcquirer.hpp:28:
In file included from /home/frolo/grappa/system/Message.hpp:27:
In file included from /home/frolo/grappa/system/MessageBase.hpp:33:
In file included from /home/frolo/grappa/system/ConditionVariableLocal.hpp:27:
/home/frolo/grappa/system/tasks/TaskingScheduler.hpp:178:25: error: no matching constructor for initialization of 'std::ofstream' (aka 'basic_ofstream<char>')
          std::ofstream f(FLAGS_stats_blob_filename);
                        ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../include/c++/4.3/fstream:571:7: note: candidate constructor not viable: no known conversion from '::fLS::clstring' (aka 'basic_string<char>') to 
'const char *' for 1st argument
      basic_ofstream(const char* __s,
      ^
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../include/c++/4.3/bits/fstream.tcc:916:25: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from '::fLS
::clstring' (aka 'basic_string<char>') to 'const std::basic_ofstream<char>' for 1st argument
  extern template class basic_ofstream<char>;

...

看起来gcc 4.3.4和clang 3.5之间不兼容,不是吗?我不是一个有经验的clang用户,可以在这里做些什么来修补它?

感谢您的帮助!

最佳,   亚历

1 个答案:

答案 0 :(得分:0)

Clang 3.5使用gcc 4.7 ABI,因此您应该使用gcc&gt; = 4.7进行编译。或者,您可以从this site为基于Ubuntu / Debian的Linux发行版下载.deb格式的夜间LLVM / Clang版本。