- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was new for icc and is trying to compile a hello word using icpc
[cpp]
#include <string>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
cout<<"Hello World"<<endl;
}
[/cpp]
When I use "icc -o test main.cpp", "g++ -o test main.cpp", it works normally.
But if I try to use "icpc -o test main.cpp", it will appear error like below:
[cpp]
In file included from /usr/include/c++/4.8/string(41),
from main.cpp(1):
/usr/include/c++/4.8/bits/allocator.h(92): error: __allocator_base is not a template
class allocator: public __allocator_base<_Tp>
^
In file included from /usr/include/c++/4.8/string(41),
from main.cpp(1):
/usr/include/c++/4.8/bits/allocator.h(92): error: not a class or struct name
class allocator: public __allocator_base<_Tp>
^
compilation aborted for main.cpp (code 2)
[/cpp]
Is there any setting should I know before using icpc?
I am using Intel C++ Composer XE 2013 SP1 for Linux on Ubuntu 12.04.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't have an Ubuntu 12.04 to reproduce with
Can you send this information:
icc -# main.cpp >& invoke-icc.txt
icpc -# main.cpp >& invoke-icpc.txt
icc -E main.cpp > mainE.icc.txt
icpc -E main.cpp > mainE.icpc.txt
then attach all 4 text files.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Icc is seeing gcc 4.6 headers and icpc is seeing gcc 4.8 headers. Does g++ invoke 4.6 or 4.8? (g++ -v) If g++ is 4.6, see if you have a g++-4.8 binary (or something like it) and try using that to compile your example (e.g. g++-4.8 -o test main.cpp). If g++ 4.8 fails to build it, then something is wrong with your g++ 4.8 installation and you'll need to correct that so that icpc can work with those headers.
You can test which headers icpc is using with "icpc -v" and change which headers it uses with the -gcc-name compiler option.
I can compile your example with icpc 14.0 and g++ 4.8.1, so I tend to think the problem is with the gcc 4.8 installation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I use g++-4.8 from ppa:ubuntu-toolchain-r/test with cpp-4.8, gcc-4.8, g++-4.8, libstdc++-4.8-dev.
I've test "g++-4.8 -o test main.cpp" and it's fine.
"icpc -v" only shows its version
[bash]
$ icpc -v
icpc version 14.0.0 (gcc version 4.8.0 compatibility)
[/bash]
and below is my "g++ -v"
[bash]
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.1-2ubuntu1~12.04' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.1 (Ubuntu 4.8.1-2ubuntu1~12.04)
[/bash]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Intel compiler bug database has an include path issue specific to Ubuntu, DPD200341110, which is similar.
From looking at the preprocessed file which you uploaded, I see that the icpc compilation is pulling in "/usr/include/x86_64-linux-gnu/c++/4.7/bits/c++config.h", which is the source of the incompatibility with the gcc 4.8 header files that's causing the compilation error with __allocator_base
You can workaround the include file problem like this: preprocess the source with g++, figure out where "bits/c++config.h" is coming from, then add that include path like this: -I/directory-where-bits-slash-config.h-is located
You can modify your environment to add the include dir on every compilation: export __INTEL_POST_CFLAGS=-I/directory-where-bits-slash-config.h-is-located
Something in your environment is causing icc compilation to pick up gcc 4.6 whereas your icpc compilation is picking up gcc 4.8, it's best to make sure that both c compilation and c++ compilation are both using the same version of gcc. You can do this by using compilation options -gcc-name= -gxx-name=
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've use "g++ -E main.cpp > mainE.g++.txt" and fonud the c++config.h should be at "/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++config.h".
So I test the command "icpc -l/usr/include/x86_64-linux-gnu/c++/4.8/bits -o test main.cpp" but still with same error, and same preprocessed file.
I've to force gcc to be 4.6 cause I use CUDA and CUDA is incompatible with gcc 4.8. I do this by set /usr/local/cuda/bin/gcc to link gcc-4.6.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please use this: "icpc -l/usr/include/x86_64-linux-gnu/c++/4.8 -o test main.cpp"
The reason being that the #include itself says "#include bits/c++config.h", so you need to not mention the bits directory in the -I option
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It still don't work, and still with same error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Changlin, could you try telling the compiler which g++ you would like to use by adding the option -gxx-name=/path/to/bin/g++
and adding -cxxlib=/path/to/4.6/gcc/installation.
Let us know those two options clear up the problems you are having with the headers.
Regards,
Kenneth
Intel Developer Support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can confirm this bug ("__allocator_base is not a template") on Ubuntu 13.04, as well as Ubuntu 13.10 (upgrade didn't change behavior). I discovered it when trying to compile Scipy. I can also confirm that changing my system GCC to 4.7 fixes the problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry for forget to report...
I've change my gcc back to 4.8 cause CUDA 5.5 has support it, so I test...
[bash]
$ icpc -gxx-name=/usr/bin/g++-4.8 -o test main.cppIn file included from /usr/include/c++/4.8/string(41),
from main.cpp(1):
/usr/include/c++/4.8/bits/allocator.h(92): error: __allocator_base is not a template class allocator: public __allocator_base<_Tp>
^
In file included from /usr/include/c++/4.8/string(41),
from main.cpp(1):
/usr/include/c++/4.8/bits/allocator.h(92): error: not a class or struct name class allocator: public __allocator_base<_Tp>
^
[/bash]
I use apt-get to install gcc, so I don't know where to specify cxxlib.
I've test changing to gcc 4.7 and it works like Eric, but I need some c++11 feature so I need gcc 4.8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't know if you are still looking for a solution, but...
Using Mint version 16, a Ubuntu derivitive, I got the same error.
The fix above says,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'd like to report that with icpc 14.0.1 on Ubuntu 13.10, -I/usr/include/x86_64-linux-gnu/c++/4.8 (capital I, not lower case l) does work -- btw, nice catch here.
I'm using -isystem though since it has the advantage of suppressing -Weffc++ warnings.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Please use this: "icpc -l/usr/include/x86_64-linux-gnu/c++/4.8 -o test main.cpp" The reason being that the #include itself says "#include bits/c++config.h", so you need to not mention the bits directory in the -I option
Notice that in -l/usr/include/x86_64-linux-gnu/c++/4.8 begins with an "L" (library) not an "I" (include). When I use this with an "I" (include), i.e. -I/usr/include/x86_64-linux-gnu/c++/4.8 ... IT WORKS.
I don't know why this problem exists with Ubuntu.