[Dune-devel] SOCIS 2014: build system issue

Jö Fahlke jorrit at jorrit.de
Wed Jul 9 15:45:13 CEST 2014


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 828 bytes
Desc: Digital signature
URL: <https://lists.dune-project.org/pipermail/dune-devel/attachments/20140709/cee056f1/attachment.sig>


More information about the Dune-devel mailing list