ornladios / ADIOS2-Examples

Application examples for the ADIOS2 I/O library https://github.com/ornladios/ADIOS2. This is Work in Progress.
Apache License 2.0
20 stars 16 forks source link

Missing -pthread option for cmake build? #36

Closed dmitry-ganyushin closed 3 years ago

dmitry-ganyushin commented 4 years ago

Hello,

I tried to build examples using cmake and needed to add SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") into source/cpp/basics/CMakeLists.txt to be able to build adios2-thread-write-cpp

Linking CXX executable ../../../bin/adios2-thread-write-cpp /usr/bin/ld: CMakeFiles/adios2-thread-write-cpp.dir/thread-write.cpp.o: undefined reference to symbol 'pthread_create@@GLIBC_2.2.5' //lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status source/cpp/basics/CMakeFiles/adios2-thread-write-cpp.dir/build.make:109: recipe for target 'bin/adios2-thread-write-cpp' failed

pnorbert commented 4 years ago

I cannot reproduce this error with the Ubuntu 18.04.4 LTS, gcc 7.5.0 and cmake 3.17.3 or 3.16.5. Your system's difference is only cmake 3.17.2 otherwise the same.

pnorbert commented 4 years ago

@chuckatkins Do you have any idea what may go wrong here? I see the -pthread flag added in CMakeCache.txt if I run cmake. It does not seem to come from the adios2 installation (adios2-config -cxx-flags does not contain -pthread).

MPI_CXX_COMPILE_OPTIONS:STRING=-pthread
MPI_CXX_LINK_FLAGS:STRING=-Wl,-rpath -Wl,/opt/openmpi/4.0.3/lib -Wl,--enable-new-dtags -pthread

So why could this be excluded in his build?

williamfgc commented 4 years ago

@pnorbert we'd probably need to add find_package(Threads REQUIRED) and link the Threads::Threads target. We only have Ubuntu in CI.

pnorbert commented 4 years ago

Indeed, there is an example which is using threads, so we should explicitly add it here. This is not an adios or cmake problem.

williamfgc commented 4 years ago

That's another good reason to have adios2 in Debian and Fedora. We can build containers for CI more easily on projects like this.