【问题标题】:Why does an extra -I flag (include directory) break compilation? (using Intel Compiler)为什么额外的 -I 标志(包括目录)会破坏编译? (使用英特尔编译器)
【发布时间】:2014-07-01 08:13:51
【问题描述】:

我安装了 Intel ComposerXE 2013 的试用版(包含 ICC 14.0.1 编译器)。我的测试程序如下:

#include <boost/graph/adjacency_list.hpp>
#include <iostream>

typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> UndirectedGraph;

int main() {

  UndirectedGraph G(10);

return 0;  
}

我使用英特尔编译器标志编译代码如下

/home/intel/bin/icpc                                 //binary
   -L/home/intel/composerxe/lib/intel64              //lib path
   -I/home/intel/composerxe/include                  //include path for ICPC
   -I/home/boost_1_55_0                              //boost path
   -std=c++11 test.cpp                              //  c++11 flags 

对于 BOOST HASH.hpptype_traits.hpp 文件,我收到以下错误

In file included from /home/boost_1_55_0/boost/functional/hash/hash.hpp(540),
                 from /home/boost_1_55_0/boost/functional/hash.hpp(6),
                 from /home/boost_1_55_0/boost/unordered/unordered_set.hpp(20),
                 from /home/boost_1_55_0/boost/unordered_set.hpp(16),
                 from /home/boost_1_55_0/boost/graph/adjacency_list.hpp(21),
                 from test.cpp(1):
/home/boost_1_55_0/boost/functional/hash/extensions.hpp(67): error: "hash_value" is not a function or static data member
      std::size_t hash_value(std::complex<T> const&);
                  ^

In file included from /home/boost_1_55_0/boost/functional/hash/hash.hpp(540),
                 from /home/boost_1_55_0/boost/functional/hash.hpp(6),
                 from /home/boost_1_55_0/boost/unordered/unordered_set.hpp(20),
                 from /home/boost_1_55_0/boost/unordered_set.hpp(16),
                 from /home/boost_1_55_0/boost/graph/adjacency_list.hpp(21),
                 from test.cpp(1):
/home/boost_1_55_0/boost/functional/hash/extensions.hpp(121): error: "hash_value" is not a function or static data member
      std::size_t hash_value(std::complex<T> const& v)
                  ^

In file included from /home/boost_1_55_0/boost/functional/hash/hash.hpp(540),
                 from /home/boost_1_55_0/boost/functional/hash.hpp(6),
                 from /home/boost_1_55_0/boost/unordered/unordered_set.hpp(20),
                 from /home/boost_1_55_0/boost/unordered_set.hpp(16),
                 from /home/boost_1_55_0/boost/graph/adjacency_list.hpp(21),
                 from test.cpp(1):
/home/boost_1_55_0/boost/functional/hash/extensions.hpp(277): warning #12: parsing restarts here after previous syntax error
      };
       ^

In file included from /home/boost_1_55_0/boost/type_traits.hpp(49),
                 from /home/boost_1_55_0/boost/pending/property.hpp(13),
                 from /home/boost_1_55_0/boost/graph/graph_traits.hpp(27),
                 from /home/boost_1_55_0/boost/graph/adjacency_list.hpp(33),
                 from test.cpp(1):
/home/boost_1_55_0/boost/type_traits/is_complex.hpp(23): error #303: explicit type is missing ("int" assumed)
     is_convertible_from_tester(const std::complex<T>&);
                                      ^

In file included from /home/boost_1_55_0/boost/type_traits.hpp(49),
                 from /home/boost_1_55_0/boost/pending/property.hpp(13),
                 from /home/boost_1_55_0/boost/graph/graph_traits.hpp(27),
                 from /home/boost_1_55_0/boost/graph/adjacency_list.hpp(33),
                 from test.cpp(1):
/home/boost_1_55_0/boost/type_traits/is_complex.hpp(23): error: qualified name is not allowed
     is_convertible_from_tester(const std::complex<T>&);
                                      ^

In file included from /home/boost_1_55_0/boost/type_traits.hpp(49),
                 from /home/boost_1_55_0/boost/pending/property.hpp(13),
                 from /home/boost_1_55_0/boost/graph/graph_traits.hpp(27),
                 from /home/boost_1_55_0/boost/graph/adjacency_list.hpp(33),
                 from test.cpp(1):
/home/boost_1_55_0/boost/type_traits/is_complex.hpp(23): error: expected a ")"
     is_convertible_from_tester(const std::complex<T>&);
                                                  ^

In file included from /home/boost_1_55_0/boost/type_traits.hpp(49),
                 from /home/boost_1_55_0/boost/pending/property.hpp(13),
                 from /home/boost_1_55_0/boost/graph/graph_traits.hpp(27),
                 from /home/boost_1_55_0/boost/graph/adjacency_list.hpp(33),
                 from test.cpp(1):
/home/boost_1_55_0/boost/type_traits/is_complex.hpp(22): warning #488: template parameter "T" is not used in declaring the parameter types of function template "boost::detail::is_convertible_from_tester::is_convertible_from_tester"
     template <class T>
                     ^

现在我在没有 ICPC INCLUDE PATH 的情况下使用它进行编译

/home/intel/bin/icpc                                 //binary
   -L/home/intel/composerxe/lib/intel64              //lib path
                  //removed the ICPC INCLUDE PATH HERE 
   -I/home/boost_1_55_0                              //boost path
   -std=c++11 test.cpp                               // c++11 flags 

这编译得很好,零错误

为什么会这样?

我的 LD_LIBRARY_PATHPATH 变量为空。没有设置路径的 GCC 或任何其他编译器。我在编译过程中给出了所有的路径。

【问题讨论】:

  • 你不会在/home/intel/composerxe/include下安装一个boost版本吗?

标签: c++ boost icc


【解决方案1】:

可能给定目录中的某个文件与其他文件同名,当它被#included时,编译将失败或成功取决于选择这两个同名文件的哪个文件。

要验证是否是这种情况,请使用选项-H 编译这两种情况,它将列出所有包含的文件,并比较输出。

要在不删除目录的情况下解决问题,请将其移至命令行末尾:

/home/intel/bin/icpc                                 //binary
   -L/home/intel/composerxe/lib/intel64              //lib path
   -I/home/boost_1_55_0                              //boost path
   -I/home/intel/composerxe/include                  //include path for ICPC
   -std=c++11 test.cpp                              //  c++11 flags 

【讨论】:

  • 是的。 -H 选项有效。我发现包含 math.h,来自两个位置的复杂文件。如果我不提供包含路径,它工作正常。如果我提供路径,还会包含其他一些文件,因为它会显示错误。英特尔编译器包含路径有点棘手,无需提供任何包含路径。谢谢你的主意!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-09-14
  • 2021-11-07
  • 1970-01-01
  • 2020-02-05
  • 1970-01-01
  • 2021-08-08
  • 1970-01-01
相关资源
最近更新 更多