AcademySoftwareFoundation / openvdb

OpenVDB - Sparse volume data structure and tools
http://www.openvdb.org/
Mozilla Public License 2.0
2.62k stars 647 forks source link

[BUG] I cannot compile my code using NanoVDB #1711

Closed rddrdhd closed 10 months ago

rddrdhd commented 10 months ago

Environment

Operating System: CentOS 7.9 Version / Commit SHA: 9153c12ed095156aad18f4a0ca7f754b97eb83da Others: I'm new to C++ compilations

Describe the bug

I can't run make on my NanoVDB Hello World example. Already succesfully ran OpenVDB example with the library built from this repo.

To Reproduce

Steps to reproduce the behavior:

  1. Build & install OpenVDB with NanoVDB:

    • cmake .. -DUSE_NANOVDB=ON -DNANOVDB_BUILD_UNITTESTS=ON -DNANOVDB_BUILD_EXAMPLES=ON -DNANOVDB_BUILD_BENCHMARK=ON -DNANOVDB_USE_OPENVDB=ON -DCMAKE_INSTALL_PREFIX:PATH=/path/to/my/openvdb/build/install
    • make -j64
    • make install # succes
  2. Build & run NanoVDB Hello World example in main.cpp: (Just the same for OpenVDB example, except the attempt is not successfull for NanoVDB)

    • My CMakeLists.txt:
      project(main)
      set(CMAKE_CXX_STANDARD 17)
      set(CMAKE_CXX_STANDARD_REQUIRED True)
      set(CMAKE_MODULE_PATH /path/to/my/openvdb/build/install/lib64/cmake/OpenVDB)
      link_directories(/path/to/my/openvdb/build/install/lib64/cmake/OpenVDB)
      find_package(OpenVDB REQUIRED)
      add_executable(main main.cpp)
      target_link_libraries(main OpenVDB::openvdb)# OpenVDB::nanovdb) # adding this doesn't work

Additional context

I checked out a similar issue #1707 which was resolved by adding #define NANOVDB_USE_OPENVDB into my main.cpp, but it didn't help.

rddrdhd commented 10 months ago

Solved changing CMakeLists.txt:

So the file now looks like this:

cmake_minimum_required(VERSION 3.5)
project(main)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-changes-meaning")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(OPENVDB_INCLUDE_DIR "" CACHE PATH "")
set(OPENVDB_LIBRARIES "" CACHE FILEPATH "")
set(TBB_LIBRARIES "" CACHE FILEPATH "")
add_executable(main main.cpp)
target_link_libraries(main ${OPENVDB_LIBRARIES} ${TBB_LIBRARIES} pthread)
target_include_directories(main PUBLIC ${OPENVDB_INCLUDE_DIR})