Hello,
On Mon, 20 Jul 2009, Dmitriy Morozov wrote:
I am trying to compile a program that uses Boost libraries with GCC's
parallel extensions, but I get linking errors. In particular, if I
compile without the flags "-fopenmp -D_GLIBCXX_PARALLEL", then
everything works fine. However, if I add those two flags, I get the
error below. Actually, to be specific the error appears when I add
-D_GLIBCXX_PARALLEL, -fopenmp by itself does not cause problems. I
suspect the problem comes from the fact that Boost was compiled
without -D_GLIBCXX_PARALLEL.
Indeed, as documented here:
http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt12ch31s03.html
"therefore one can only link code compiled with parallel mode and code
compiled without parallel mode if no instantiation of a container is
passed between the two translation units."
and the error message shows a vector.
I was wondering if there was a way to
work around this problem, since in this example I don't need the
parallel extensions in the part of the code that uses Boost (in this
case just for command line parsing).
You could separate the code that does the option parsing and the rest in 2
separate files, one compiled with the parallel flag and one without it,
such that no container is shared by the 2 parts. Or you could explicitly
use parallel containers/algorithms where you want them so you don't need
the global flag.
You could likely get away with a simple renaming of symbols, but it is
unsupported.
--
Marc Glisse