[joss-review] Building in debug mode causes linker errors for `tbb`
To reproduce:
mkdir build
cd build
cmake .. -DHTOOL_WITH_EXAMPLES=True -DCMAKE_BUILD_TYPE=Debug
make Use_hmatrix
When I don't specify -DCMAKE_BUILD_TYPE=Debug or explicitly use -DCMAKE_BUILD_TYPE=Release, everything works. In debug mode, the linker complains that it cannot find some tbb::detail::bla bla functions.
This fixes it:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 63d568d..042388c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -109,7 +109,7 @@ find_package(HPDDM)
#=== HTOOL as header only library
add_library(htool INTERFACE)
target_include_directories(htool INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> ${HPDDM_INCLUDE_DIRS} ${MKL_INC_DIR})
-target_link_libraries(htool INTERFACE MPI::MPI_CXX BLAS::BLAS LAPACK::LAPACK)
+target_link_libraries(htool INTERFACE MPI::MPI_CXX BLAS::BLAS LAPACK::LAPACK tbb)
if(OpenMP_CXX_FOUND)
target_link_libraries(htool INTERFACE OpenMP::OpenMP_CXX)
endif()
but I have no idea why this is not necessary in Release mode.
cc: https://github.com/openjournals/joss-reviews/issues/9279
Could share the full log and give more details on your environment (OS, compiler, etc.) ?
The CI tests for (Debian x Ubuntu) x (gcc x clang) x (OpenMPI x MPICH) in Debug mode, so it is a little bit surprising.
I've been able to reproduce the issue, let me sort this out with @PierreMarchand20, thanks for the report.
I am on Ubuntu 24.04 using gcc 13.3. An answer on stackoverflow suggested to remove the libtbb-dev package and that indeed fixed the issue. No idea what's going on, but it's certainly not a htool problem.
Edit: @prj- I saw your comment too late and already closed the issue (and apparently I don't have permission to reopen).
In the meantime, you should be able to bypass the issue by setting -DCMAKE_CXX_COMPILER=mpiicpx (or whatever flag to force the use of Intel compiler instead of g++).
We need to sort this out, I've the same issue on a machine where I don't have root privileges, so it's not as easy as removing the faulty package. But yeah, not really an Htool issue per say.
@nilsfriess We fixed the issue with the reproducer of @prj- in #70.
But in the reproducer, the issue came from using MKL, so that TBB was in the include path (because of the setvars.h when using oneapi), and for some reasons, the compiler then tries to use TBB that it cannot find when linking. So we added TBB link flag when using MKL. I am not 100% sure it solves the issue you encountered though. Could you try with #70 if it works for you?
Could you try with https://github.com/htool-ddm/htool/pull/70 if it works for you?
You'll have to reinstall the faulty package first.
This is fixed in #70. Do not hesitate to reopen if there is still an issue with TBB.