Issue when building debug version

System/OS/Software:

  • Windows 10 64
  • Visual Studio 2019
  • CMake 3.18.4

Steps to reproduce:

  • Clone Open3D recousively according to documentation

  • In Cmake GUI set source to repo folder and create build folder, change DCMAKE_INSTALL_PREFIX=C:/Opend3D, build without python module (but change python path to correct Anaconda python exe files regardless)

  • configure (until nothing is red in Cmake) and generate project for Visual Studio 2019 64

  • Start Visual Studio 2019 as Administrator (since install prefix is directly in C:/)

  • config to release

  • build target ALL_BUILD

  • build target INSTALL

  • Clone open3d-cmake-find-package

  • Again config and generate with Cmake GUI (only change path to Open3D install cmake file location)

  • Open VS2019 -> release config

  • Build and run draw.cpp

The issue:
Everything above only works as long as the project, which references the Open3D install is set to release. As soon as config is changed to debug many of the following error type appear: (this being only an example)

Severity Code Description Project File Line Suppression State
Error LNK2038 mismatch detected for ‘_ITERATOR_DEBUG_LEVEL’: value ‘0’ doesn’t match value ‘2’ in TriangleMesh.obj TriangleMesh C:\Users\Johannes\source\repos\Open3D\Open3D\build\examples\cpp\jsoncpp.lib(json_value.obj)

Same things happen if I create an empty c++ project and reference the Open3D lib (basically copying the projects options (linker,…) from the open3d-cmake-find-package project.

Reading the issue Windows install separate debug and release libs #2131 (sorry, can’t add more links as new user) on the Github repo, I tried to rebuild Open3D in debug config again with a different install prefix to the release version, however building fails with 258 errors, which are similar to the errors above:

Severity Code Description Project File Line Suppression State
Error src/lib_json/CMakeLists.txt: patch does not apply ext_jsoncpp (ExternalProjectTargets\ext_jsoncpp\ext_jsoncpp) C:\Users\Johannes\source\repos\Open3D\Open3D\build\CUSTOMBUILD 1
Error patch failed: src/lib_json/CMakeLists.txt:125 ext_jsoncpp (ExternalProjectTargets\ext_jsoncpp\ext_jsoncpp) C:\Users\Johannes\source\repos\Open3D\Open3D\build\CUSTOMBUILD 1
Error patch failed: CMakeLists.txt:22 ext_jsoncpp (ExternalProjectTargets\ext_jsoncpp\ext_jsoncpp) C:\Users\Johannes\source\repos\Open3D\Open3D\build\CUSTOMBUILD 1
Error LNK2038 mismatch detected for ‘_ITERATOR_DEBUG_LEVEL’: value ‘0’ doesn’t match value ‘2’ in Voxelization.obj Voxelization C:\Users\Johannes\source\repos\Open3D\Open3D\build\examples\cpp\jsoncpp.lib(json_value.obj) 1
Error LNK2038 mismatch detected for ‘_ITERATOR_DEBUG_LEVEL’: value ‘0’ doesn’t match value ‘2’ in Voxelization.obj Voxelization C:\Users\Johannes\source\repos\Open3D\Open3D\build\examples\cpp\jsoncpp.lib(json_reader.obj) 1

Weirdly enough, I got it to work now. Here is what I did:

-completely deleted the build folder
-reconfigured and generated the project with cmake, using a different install prefix folder.
-in VS2019 build ALL_BUILD and INSTALL in debug configuration.

Now I have two Open3D installation folders, one that is referenced in my project when in release configuration and one that is referenced when in debug configuration.

Still, it would be interesting, why this is needed I guess.