InteractiveComputerGraphics/Discregrid

Error when compiling with clang

cesss opened this issue · 9 comments

cesss commented

When compiling with clang 7.0, I'm getting this error:

discregrid/include/Discregrid/acceleration/kd_tree.inl:188:32: error:
variable 'node' declared with deduced type 'const auto &' cannot appear in its own initializer
auto const& node = node(node_index);
______________________^

I believe clang is right at considering this an error, although I'm no expert in newer C++ syntax.

Got that problem as well.

This problem should be fixed now.

The issue appears also when using nvcc.
Should I open a new issue for that?

I fixed this issue for the clang compiler. Since this project does not support CUDA, I am not sure what you do with the nvcc compiler.

Could anyone help with the following issue.
When compiling in Mac OS 10.15.1, I got the error message:

CMake Error at /usr/local/Cellar/cmake/3.15.5/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS)
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.15.5/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/Cellar/cmake/3.15.5/share/cmake/Modules/FindOpenMP.cmake:477 (find_package_handle_standard_args)
  discregrid/CMakeLists.txt:78 (find_package)

-- Configuring incomplete, errors occurred!

Then I add the following code to find OpenMP, and it does finish the configuration:

if(APPLE AND USE_OpenMP)
    if(CMAKE_C_COMPILER_ID MATCHES "Clang")
        set(OpenMP_C "${CMAKE_C_COMPILER}")
        set(OpenMP_C_FLAGS "-fopenmp=libomp ") #-Wno-unused-command-line-argument
        set(OpenMP_C_LIB_NAMES "libomp" "libgomp" "libiomp5")
        set(OpenMP_libomp_LIBRARY ${OpenMP_C_LIB_NAMES})
        set(OpenMP_libgomp_LIBRARY ${OpenMP_C_LIB_NAMES})
        set(OpenMP_libiomp5_LIBRARY ${OpenMP_C_LIB_NAMES})
    endif()
    if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
      set(OpenMP_CXX "${CMAKE_CXX_COMPILER}")
      set(OpenMP_CXX_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
      set(OpenMP_CXX_LIB_NAMES "libomp" "libgomp" "libiomp5")
      set(OpenMP_libomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
      set(OpenMP_libgomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
      set(OpenMP_libiomp5_LIBRARY ${OpenMP_CXX_LIB_NAMES})
    endif()
endif()

if(USE_OpenMP)
  find_package(OpenMP REQUIRED)
endif(USE_OpenMP)
-- Found OpenMP_C: -fopenmp=libomp   
-- Found OpenMP_CXX: -fopenmp=libomp -Wno-unused-command-line-argument  
-- Found OpenMP_C: -fopenmp=libomp   
-- Found OpenMP_CXX: -fopenmp=libomp -Wno-unused-command-line-argument  
-- Configuring done
-- Generating done

However, there might be something wrong, since the following message appears when I compile :

clang: error: unsupported argument 'libomp' to option 'fopenmp='
make[2]: *** [discregrid/CMakeFiles/Discregrid.dir/src/discrete_grid.cpp.o] Error 1
make[1]: *** [discregrid/CMakeFiles/Discregrid.dir/all] Error 2
make: *** [all] Error 2

Addressed by #6
Open MP can be installed using homebrew by running

brew install libomp

This open mp version will then be found and used by the cmake script.

Thanks for your reply, @digitalillusions . I have actually done this before, but it didn't work.

That's strange. I tested it on MacOS 10.15.1 as well and it compiles and runs with OpenMP enabled. Have you attempted building with the new commit? If so, what error do you get?

The problem is fixed now. Thanks!