Link error with icpc when using Boost* 1.51+ MPL library and g++*

Problem

Link error with icpc: when linking object files compiled with icpc & g++* along with Boost* MPL library 1.51 or above, as shown in the sample test case below:

%cat t.h
#include <boost/mpl/vector.hpp>
template<typename T> struct my;
void foo(my<boost::mpl::vector<> >* = 0);

%cat u.cpp
#include "t.h"
int main() { foo();}

%cat t.cpp
#include "t.h"
void foo(my<boost::mpl::vector<> >*) {}

%icpc  -c  -I$BOOST_INC   u.cpp
%g++  -c   -I$BOOST_INC  t.cpp
%icpc u.o t.o
u.o: In function `main':
u.cpp:(.text+0x2b): undefined reference to `foo(my<boost::mpl::vector<boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, b:mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::nost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na> >*)'

Environment

Windows* IA32 or Intel® 64 systems; Intel® Composer XE 2013 Update 2 or older (for Windows* or Linux*)

Root Cause

When using icpc to link object files compiled icpc and g++ along with Boost (MPL library) versions 1.51+ as shown in the example above, you will get a linker error with undefined references to mpl template parameters. The problem is related to an issue of icpc handling of the ADL barrier namespace index in the code.

Resolution

We are working with Boost library folks to address this issue. Until then, you can use the workaround below:

  1. Go to "./boost/mpl/aux/config" directory
  2. Comment out the following line in the file adl.hpp
             || BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, BOOST_TESTED_AT(810))
Para obter informações mais completas sobre otimizações do compilador, consulte nosso aviso de otimização.