[Dune-devel] SOCIS 2014: build system issue
Agnese, Marco
m.agnese13 at imperial.ac.uk
Thu Jul 10 01:51:20 CEST 2014
Hi,
I am using autotools and the -pthread flag is presents also at the linking phase.
The precise error message is
terminate called after throwing an instance of 'std::system_error'
what(): Enable multithreading to use std::thread: Operation not permitted
Aborted (core dumped)
Looking the dynamic dependencies, the libthread one is missing.
The full compile command is
g++ -std=c++11 -DHAVE_CONFIG_H -I. -I../../.. -I../../.. -I/usr/local_machine/openmpi-1.6.5/include -pthread -DMPIPP_H -DENABLE_MPI=1 -O3 -Wall -DNDEBUG -funroll-loops -finline-functions -pthread -fomit-frame-pointer -ffast-math -mfpmath=sse -msse3 -MT threadstest-threadstest.o -MD -MP -MF .deps/threadstest-threadstest.Tpo -c -o threadstest-threadstest.o `test -f 'threadstest.cc' || echo './'`threadstest.cc
mv -f .deps/threadstest-threadstest.Tpo .deps/threadstest-threadstest.Po
/bin/bash ../../../libtool --tag=CXX --mode=link g++ -std=c++11 -O3 -Wall -DNDEBUG -funroll-loops -finline-functions -pthread -fomit-frame-pointer -ffast-math -mfpmath=sse -msse3 -o threadstest threadstest-threadstest.o -pthread -L/usr/local_machine/openmpi-1.6.5/lib -lmpi -ldl -lm -Wl,--export-dynamic -lrt -lnsl -lutil -lm -ldl ../../../lib/libdunecommon.la -lm
libtool: link: g++ -std=c++11 -O3 -Wall -DNDEBUG -funroll-loops -finline-functions -pthread -fomit-frame-pointer -ffast-math -mfpmath=sse -msse3 -o threadstest threadstest-threadstest.o -pthread -Wl,--export-dynamic -L/usr/local_machine/openmpi-1.6.5/lib /usr/local_machine/openmpi-1.6.5/lib/libmpi.so -lrt -lnsl -lutil -ldl ../../../lib/.libs/libdunecommon.a -llapack -lblas -lgfortran -lquadmath -lm -pthread -Wl,-rpath -Wl,/usr/local_machine/openmpi-1.6.5/lib -Wl,-rpath -Wl,/usr/local_machine/openmpi-1.6.5/lib
Is it possible to merge this macro of EXADUNE in dune-common to have the possibility to link the thread library properly just adding the $(STD_THREAD_LDFLAGS) automake-rule?
Thank you,
cheers,
Marco.
From: Jö Fahlke [jorrit at jorrit.de]
Sent: Wednesday, July 09, 2014 2:45 PM
To: Agnese, Marco
Cc: dune-devel at dune-project.org
Subject: Re: [Dune-devel] SOCIS 2014: build system issue
Am Wed, 9. Jul 2014, 11:59:58 +0000 schrieb Agnese, Marco:
> I have a small issue when I compile my projects using thread. More precisely my codes compile correct but the thread library is not linked.
>
> I have compiled the module both with the option -std=C++1 and -pthread. A workaround to fix this linking issue is to append the the flag
The linker also needs -pthread, not just the compiler.
> -Wl,--no-as-needed
>
> at the end of the linking command.
>
> I think that the build system should produce a Makefile which links correctly the -pthread library without using this workaround. I do not know how to modify it therefore I need your help.
>
> This workaround it is not necessary when compiling a plain c++ code. Indeed it is sufficient g++ -std=C++11 -pthread -o test test.cc. I don't understand why it is necessary this additional flag with DUNE.
Are you using autotools or cmake?
For autotools, there is a macro specifically for this purpose (determining
extra flags needed when using std::thread) in EXADUNE. I'll see to it that it
is backported.
You're still going to need to add $(STD_THREAD_LDFLAGS) etc. to the
automake-rule for building your executable.
The reason why this needs to be specified explicitely: We usually want to
avoid linking against libraries that aren't actually needed for a particular
executable, and there are dune programs that don't need threads. The -pthread
flag usually instructs the linker to link to some library providing the
pthread functions.
Regards,
Jö.
--
Jorrit (Jö) Fahlke, Institute for Computational und Applied Mathematics,
University of Münster, Orleans-Ring 10, D-48149 Münster
Tel: +49 251 83 35146 Fax: +49 251 83 32729
Software is like sex; it's better when it's free.
-- Linus Torvalds
More information about the Dune-devel
mailing list