Reputation: 23
I am having a hard time compiling a bit of c++ code using intel compiler, while GCC compiler does the job without errors.
Consider the following main function:
Main.cpp
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <stdio.h>
#include "my_func_data.h"
int main()
{
my_func_data dataFunction;
dataFunction.vec.push_back(1);
dataFunction.vec.push_back(2);
dataFunction.vec.push_back(3);
dataFunction.vec.push_back(4);
for(int i=0;i<4;i++){
printf("%f\n",dataFunction.vec[i]);
}
return 0;
}
where my_func_data.h is a structure that has to be in a separate header file (for the purpose of demonstrating the issue).
#ifndef my_func_data_H_
#define my_func_data_H_
#include <stdio.h>
#include <stdlib.h>
#include <vector>
typedef struct
{
std::vector<double>vec;
}
my_func_data;
#endif
Now I load two compilers and try to compile the two functions using each.
1st using gnu compiler:
module load compiler/gnu-6.2.0
g++ -std=c++11 Main.cpp my_func_data.h -o main
./main
1.000000
2.000000
3.000000
4.000000
Next using intel compiler
module load compiler/intel-15.0
icc -std=c++11 Main.cpp my_func_data.h -o main
icc: command line warning #10370: option '-std=c++11' is not valid for C compilations
my_func_data.h(6): catastrophic error: cannot open source file "vector"
#include <vector>
^
what could prevent ICC compiler from compiling the code? Moreover, should I embed the structure my_func_data in the main function it compiles and executes all right.
Thank you in advance for any insights!
Upvotes: 2
Views: 1254
Reputation: 71525
icc
is the C compiler. The C++ compiler is icpc
.
This is similar to gcc
vs. g++
.
Upvotes: 3
Reputation: 206577
Problems:
-std=c++11
is not a valid compiler option. See the list of valid compiler options.You don't need to use my_func_data.h
in the command line. Simply use:
icc Main.cpp -o main
Upvotes: 0