DGtal-team / DGtal

Digital Geometry Tools and Algorithm Library
https://dgtal.org
GNU Lesser General Public License v3.0
370 stars 115 forks source link

OpenMP FLAGS incomplete: examples/topology/generateVoxelComplexTables #1323

Closed fafesche closed 6 years ago

fafesche commented 6 years ago

Configuration : gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609 OPENMP is activated for the DGtal compilation

Led to errors: [...]/DGtal/src/DGtal/topology/VoxelComplex.ih:842 : undefined_reference « omp_get_num_procs » [...]/DGtal/src/DGtal/topology/VoxelComplex.ih:843 : undefined_reference « omp_set_num_threads » [...]/DGtal/src/DGtal/topology/VoxelComplex.ih:855 : undefined_reference « omp_get_thread_num » collect2: error: ld returned 1 exit status examples/topology/CMakeFiles/generateVoxelComplexTables.dir/build.make:300 : la recette pour la cible « examples/topology/generateVoxelComplexTables » a échouée (failed to build « examples/topology/generateVoxelComplexTables »)

Origin of the problem: In file « examples/topology/CMakeFiles/generateVoxelComplexTables.dir/link.txt », compilation option: -fopenmp is missing leading to the error. Should have been included in CXX_FLAGS before.

Adding it corrected the problem and compilation was fine.

Best, Fabien Feschet

dcoeurjo commented 6 years ago

hi @fafesche, thanks for the report. The issue seems to be related to the openmp lib (which implements the omp_get_thread*) rather than the -fopenmp.

but I agree.. OpenMP dependency is not set correctly in this code.

fafesche commented 6 years ago

hi @dcoeurjo -fopenmp is mandatory in gcc to activate openMP. Incuding omp.h is not sufficient to tell to gcc to do the linkage. To my point of view the actual code is correct with respect to OpenMP standard, this is only a problem with the link.

dcoeurjo commented 6 years ago

Agree but there are two things: the compiler flag (-f openmp for gcc) and the static/dyn library that implements the omp_* functionalities. It looks like the flag is ok on my systems but the lib is missing... I'll fix this and we'll see if you still have the issue.

(can you please cut/paste the output of the cmake .. command ?)

dcoeurjo commented 6 years ago

the openmp flags could also be in the flags.make file. Can you please double-check ?

fafesche commented 6 years ago

threre is no external lib for gcc it is included with (libgomp). This is different for another compiler. I have just verified: no -fopenmp in flags.make file.

dcoeurjo commented 6 years ago

strange.. Can you please cut/paste the cmake output ?

fafesche commented 6 years ago

You can close the issue I have found the origin of the problem.

Precision: I use the git version. Cloning done 2 days ago.

Command: cmake -DWITH_CAIRO=true -DWITH_EIGEN=true -DWITH_FFTW3=true -DWITH_GMP=true -DWITH_HDF5=true -DWITH_ITK=true -DWITH_MAGICK=true -DWITH_OPENMP=true -DWITH_QGLVIEWER=true -DWITH_QT5=true ..

Compilation is now ok.

Reason: two gcc version conflicting, gcc 5.4.0 conflicts with gcc-7.1 manually installed. This was not a problem of DGtal but a problem of my gcc 7-1 install. Solved this conflicting path and then all is fine.

Sorry for that. All the best.

dcoeurjo commented 6 years ago

Ok I see.. no problem, you actually helped us to fix a link issue (see the PR #1324) for some compilers with external libs.

dcoeurjo commented 6 years ago

thx