Closed msebregts closed 2 years ago
It looks like the problem is that libmuscle.so and libmuscle_mpi.so aren't built with -pthread
. As a result, they don't link with libpthread, and so pthread_create
isn't found. MUSCLE uses threads internally in the communication part, so it has a private dependency on pthread, but the model built against libmuscle shouldn't need -pthread unless it uses threads itself.
So I think the solution is to build the shared libraries with -pthread, and to add some clauses to the pkg-config files that add -pthread
to the flags and the libs when linking statically (because a .a static library doesn't contain dependency links). That way pthread should be available exactly when needed.
Released in 0.5.0.
When compiling and linking a muscle program in two steps, the linker doesn't recognize it needs to link against pthread:
Reproduction:
cd docs/source/examples/cpp
g++ `pkg-config --cflags libmuscle ymmsl` reaction.cpp `pkg-config --libs libmuscle ymmsl`
g++ `pkg-config --cflags libmuscle ymmsl` -o reaction.o -c reaction.cpp
g++ reaction.o -o reaction `pkg-config --libs libmuscle ymmsl`
Outputs a failure:/usr/bin/ld: <install_dir>/lib/libmuscle.so: undefined reference to `pthread_create'
Suggested solution:
Add
-lpthread
to theLibs
section in the variouslibmuscle*.pc
files