tudelft3d / City3D

Large-scale LoD2 Building Reconstruction from Airborne LiDAR Point Clouds
https://github.com/tudelft3d/City3D
GNU General Public License v3.0
223 stars 36 forks source link

[BUG] - CGAL::Shape_detection::Point_set, Build error on Windows #37

Closed BATspock closed 3 months ago

BATspock commented 4 months ago

Describe the bug I am using CGAL 5.6 and I was able to generate using CMake, however when trying the nmake command I run into this error, here is the complete log:

[ 98%] Building CXX object code/method/CMakeFiles/method.dir/reconstruction.cpp.obj
reconstruction.cpp
[ 98%] Building CXX object code/method/CMakeFiles/method.dir/method_global.cpp.obj
method_global.cpp
[ 98%] Building CXX object code/method/CMakeFiles/method.dir/point_set_region_growing.cpp.obj
point_set_region_growing.cpp
C:\Users\akish\Documents\City3D\code\method\point_set_region_growing.cpp(233): error C2661: 'CGAL::Shape_detection::Point_set::Sphere_neighbor_query<Kernel,Point_vector,Point_map>::Sphere_neighbor_query': no overloaded function takes 2 arguments
C:\Users\akish\Documents\City3D\code\method\point_set_region_growing.cpp(236): error C2661: 'CGAL::Shape_detection::Point_set::Least_squares_plane_fit_region<Kernel,Point_vector,Point_map,Normal_map>::Least_squares_plane_fit_region': no overloaded function takes 4 arguments
C:\Users\akish\Documents\vcpkg\installed\x64-windows\include\CGAL/Shape_detection/Region_growing/Region_growing.h(86): error C2039: 'Primitive': is not a member of 'CGAL::Shape_detection::Point_set::Sphere_neighbor_query<Kernel,Point_vector,Point_map>'
C:\Users\akish\Documents\City3D\code\method\point_set_region_growing.cpp(208): note: see declaration of 'CGAL::Shape_detection::Point_set::Sphere_neighbor_query<Kernel,Point_vector,Point_map>'
C:\Users\akish\Documents\City3D\code\method\point_set_region_growing.cpp(240): note: see reference to class template instantiation 'CGAL::Shape_detection::Region_growing<Point_vector,Neighbor_query,Region_type>' being compiled
C:\Users\akish\Documents\vcpkg\installed\x64-windows\include\CGAL/Shape_detection/Region_growing/Region_growing.h(86): error C2146: syntax error: missing '>' before identifier 'Primitive'
C:\Users\akish\Documents\City3D\code\method\point_set_region_growing.cpp(239): error C2661: 'CGAL::Shape_detection::Region_growing<Point_vector,Neighbor_query,Region_type>::Region_growing': no overloaded function takes 3 arguments
C:\Users\akish\Documents\City3D\code\method\point_set_region_growing.cpp(263): error C2672: 'CGAL::Shape_detection::Region_growing<Point_vector,Neighbor_query,Region_type>::unassigned_items': no matching overloaded function found
C:\Users\akish\Documents\City3D\code\method\point_set_region_growing.cpp(263): error C2780: 'ItemOutputIterator CGAL::Shape_detection::Region_growing<Point_vector,Neighbor_query,Region_type>::unassigned_items(const InputRange &,ItemOutputIterator,ItemMap) const': expects 3 arguments - 1 provided
C:\Users\akish\Documents\vcpkg\installed\x64-windows\include\CGAL/Shape_detection/Region_growing/Region_growing.h(430): note: see declaration of 'CGAL::Shape_detection::Region_growing<Point_vector,Neighbor_query,Region_type>::unassigned_items'
NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.32.31326\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.32.31326\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.

Here are the details of my CGAL:

// Copyright (c) 2009  
// Utrecht University (The Netherlands),
// ETH Zurich (Switzerland),
// INRIA Sophia-Antipolis (France),
// Max-Planck-Institute Saarbruecken (Germany),
// and Tel-Aviv University (Israel).  All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s)     : -

// This file is automatically created by cmake
// Do not edit manually.

#ifndef CGAL_VERSION_H
#define CGAL_VERSION_H

#define CGAL_VERSION 5.6-I-900
#define CGAL_VERSION_NR 1050600900
#define CGAL_SVN_REVISION 99999

#define CGAL_RELEASE_DATE 20240308

#include <CGAL/version_macros.h>

#endif

CMake output:

C:\Users\akish\Documents\City3D\Release>cmake -G "NMake Makefiles" ^
More? -DCMAKE_BUILD_TYPE=Release ^
More? -DBOOST_ROOT="C:\Users\akish\Downloads\boost_1_82_0\boost_1_82_0" ^
More? -DBoost_LIBRARY_DIR="C:\Users\akish\Downloads\boost_1_82_0\boost_1_82_0\stage\lib" ^
More? -DGMP_INCLUDE_DIR="C:\Users\akish\Documents\vcpkg\installed\x64-windows\include" ^
More? -DGMP_LIBRARIES="C:\Users\akish\Documents\vcpkg\installed\x64-windows\lib\gmp.lib" ^
More? -DGMPXX_LIBRARIES="C:\Users\akish\Documents\vcpkg\installed\x64-windows\lib\gmpxx.lib" ^
More? -DMPFR_INCLUDE_DIR="C:\Users\akish\Documents\vcpkg\installed\x64-windows\include" ^
More? -DMPFR_LIBRARIES="C:\Users\akish\Documents\vcpkg\installed\x64-windows\lib\mpfr.lib" ^
More? -DGUROBI_CXX_LIBRARY="C:\gurobi1101\win64\lib\gurobi_c++.md2017.lib" ^
More? -DGUROBI_CXX_LIBRARY_DEBUG="C:\gurobi1101\win64\lib\gurobi_c++d2017.lib" ^
More? -DGUROBI_LIBRARY="C:\gurobi1101\win64\lib\gurobi1101.lib" ^
More? -DCGAL_DIR="C:\Users\akish\Documents\vcpkg\installed\x64-windows\share\cgal" ^
More? ..
-- The C compiler identification is MSVC 19.32.31332.0
-- The CXX compiler identification is MSVC 19.32.31332.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Boost: C:/Users/akish/Downloads/boost_1_82_0/boost_1_82_0 (found version "1.82.0")
-- Found Boost-1.82.
-- Found OpenGL: opengl32
-- Found GUROBI: C:/gurobi1101/win64/include
-- Could NOT find GUROBI (missing: GUROBI_LIBRARIES)
-- Visual Leak Detector (VLD) is not found.
-- Using header-only CGAL
-- Targeting NMake Makefiles
-- Target build environment supports auto-linking
-- Using VC toolset 143.
-- Found GMP: C:\Users\akish\Documents\vcpkg\installed\x64-windows\lib\gmp.lib
-- Found MPFR: C:\Users\akish\Documents\vcpkg\installed\x64-windows\lib\mpfr.lib
-- Found Boost: C:/Users/akish/Downloads/boost_1_82_0/boost_1_82_0 (found suitable version "1.82.0", minimum required is "1.66")
-- Boost include dirs: C:/Users/akish/Downloads/boost_1_82_0/boost_1_82_0
-- Boost libraries:
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Found CGAL: 5.6
-- Build type: Release
-- USING CXXFLAGS = '/DWIN32 /D_WINDOWS /W3 /GR /EHsc /MD /O2 /Ob2 /DNDEBUG'
-- USING EXEFLAGS = '/machine:x64 /INCREMENTAL:NO'
-- Requested component: Core
CGAL_CXX_FLAGS_INIT:
CGAL_LIBRARIES: CGAL::CGAL_Core;CGAL::CGAL
CGAL_3RD_PARTY_LIBRARIES:
GMP_INCLUDE_DIR: C:\Users\akish\Documents\vcpkg\installed\x64-windows\include
GMP_LIBRARIES: C:\Users\akish\Documents\vcpkg\installed\x64-windows\lib\gmp.lib
-- Found OpenCV: C:/Program Files/opencv/build (found version "4.7.0") found components: core imgproc
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    GUROBI_CXX_LIBRARY
    GUROBI_LIBRARY

-- Build files have been written to: C:/Users/akish/Documents/City3D/Release

I am using windows x64 powershell

Tell us how to reproduce the bug Steps to reproduce the behavior:

  1. nmake

Development/Running environment:

Can you let me know how I can resolve this issue?

LiangliangNan commented 4 months ago

Are you using the latest code? CGAL 5.6 introduced some breaking changes, which caused that issue. It has be resolved in a recent update of the code. Please test with the latest code and let me know if the problem still remains.

BATspock commented 3 months ago

Hey , I updated the code with git pull and checked for the latest code using git status. I see that the code is up to date. I rebuilt using cmake but I still see the error.

Git check:

C:\Users\akish\Documents\City3D\Release>git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

C:\Users\akish\Documents\City3D\Release>git pull
Already up to date.

Here is the error, only difference I notice is that now it throws the error on 96% compared to 98%, not sure if this is relevant. Attached are the logs:

C:\Users\akish\Documents\City3D\Release>cmake -G "NMake Makefiles" ^
More? -DCMAKE_BUILD_TYPE=Release ^
More? -DBOOST_ROOT="C:\Users\akish\Downloads\boost_1_82_0\boost_1_82_0" ^
More? -DBoost_LIBRARY_DIR="C:\Users\akish\Downloads\boost_1_82_0\boost_1_82_0\stage\lib" ^
More? -DGMP_INCLUDE_DIR="C:\Users\akish\Documents\vcpkg\installed\x64-windows\include" ^
More? -DGMP_LIBRARIES="C:\Users\akish\Documents\vcpkg\installed\x64-windows\lib\gmp.lib" ^
More? -DGMPXX_LIBRARIES="C:\Users\akish\Documents\vcpkg\installed\x64-windows\lib\gmpxx.lib" ^
More? -DMPFR_INCLUDE_DIR="C:\Users\akish\Documents\vcpkg\installed\x64-windows\include" ^
More? -DMPFR_LIBRARIES="C:\Users\akish\Documents\vcpkg\installed\x64-windows\lib\mpfr.lib" ^
More? -DGUROBI_CXX_LIBRARY="C:\gurobi1101\win64\lib\gurobi_c++.md2017.lib" ^
More? -DGUROBI_CXX_LIBRARY_DEBUG="C:\gurobi1101\win64\lib\gurobi_c++d2017.lib" ^
More? -DGUROBI_LIBRARY="C:\gurobi1101\win64\lib\gurobi1101.lib" ^
More? -DCGAL_DIR="C:\Users\akish\Documents\vcpkg\installed\x64-windows\share\cgal" ^
More? ..
-- Found Boost: C:/Users/akish/Downloads/boost_1_82_0/boost_1_82_0 (found version "1.82.0")
-- Found Boost-1.82.
-- Could NOT find GUROBI (missing: GUROBI_LIBRARIES)
-- Visual Leak Detector (VLD) is not found.
-- Using header-only CGAL
-- Targeting NMake Makefiles
-- Target build environment supports auto-linking
-- Using VC toolset 143.
-- Found Boost: C:/Users/akish/Downloads/boost_1_82_0/boost_1_82_0 (found suitable version "1.82.0", minimum required is "1.66")
-- Boost include dirs: C:/Users/akish/Downloads/boost_1_82_0/boost_1_82_0
-- Boost libraries:
-- Found CGAL: 5.6
-- Build type: Release
-- USING CXXFLAGS = '/DWIN32 /D_WINDOWS /W3 /GR /EHsc /MD /O2 /Ob2 /DNDEBUG'
-- USING EXEFLAGS = '/machine:x64 /INCREMENTAL:NO'
-- Requested component: Core
CGAL_CXX_FLAGS_INIT:
CGAL_LIBRARIES: CGAL::CGAL_Core;CGAL::CGAL
CGAL_3RD_PARTY_LIBRARIES:
GMP_INCLUDE_DIR: C:\Users\akish\Documents\vcpkg\installed\x64-windows\include
GMP_LIBRARIES: C:\Users\akish\Documents\vcpkg\installed\x64-windows\lib\gmp.lib
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/akish/Documents/City3D/Release

C:\Users\akish\Documents\City3D\Release>nmake

Microsoft (R) Program Maintenance Utility Version 14.32.31332.0
Copyright (C) Microsoft Corporation.  All rights reserved.

[ 63%] Built target 3rd_scip
[ 74%] Built target 3rd_soplex
[ 74%] Automatic MOC and UIC for target 3rd_QGLViewer-2.6.3
[ 74%] Built target 3rd_QGLViewer-2.6.3_autogen
[ 79%] Built target 3rd_QGLViewer-2.6.3
[ 79%] Built target 3rd_glew
[ 80%] Built target 3rd_rply
[ 87%] Built target 3rd_LAStools
[ 90%] Built target basic
[ 91%] Built target math
[ 95%] Built target model
[ 96%] Built target renderer
[ 96%] Building CXX object code/method/CMakeFiles/method.dir/point_set_region_growing.cpp.obj
point_set_region_growing.cpp
C:\Users\akish\Documents\City3D\code\method\point_set_region_growing.cpp(233): error C2661: 'CGAL::Shape_detection::Point_set::Sphere_neighbor_query<Kernel,Point_vector,Point_map>::Sphere_neighbor_query': no overloaded function takes 2 arguments
C:\Users\akish\Documents\City3D\code\method\point_set_region_growing.cpp(236): error C2661: 'CGAL::Shape_detection::Point_set::Least_squares_plane_fit_region<Kernel,Point_vector,Point_map,Normal_map>::Least_squares_plane_fit_region': no overloaded function takes 4 arguments
C:\Users\akish\Documents\vcpkg\installed\x64-windows\include\CGAL/Shape_detection/Region_growing/Region_growing.h(86): error C2039: 'Primitive': is not a member of 'CGAL::Shape_detection::Point_set::Sphere_neighbor_query<Kernel,Point_vector,Point_map>'
C:\Users\akish\Documents\City3D\code\method\point_set_region_growing.cpp(208): note: see declaration of 'CGAL::Shape_detection::Point_set::Sphere_neighbor_query<Kernel,Point_vector,Point_map>'
C:\Users\akish\Documents\City3D\code\method\point_set_region_growing.cpp(240): note: see reference to class template instantiation 'CGAL::Shape_detection::Region_growing<Point_vector,Neighbor_query,Region_type>' being compiled
C:\Users\akish\Documents\vcpkg\installed\x64-windows\include\CGAL/Shape_detection/Region_growing/Region_growing.h(86): error C2146: syntax error: missing '>' before identifier 'Primitive'
C:\Users\akish\Documents\City3D\code\method\point_set_region_growing.cpp(239): error C2661: 'CGAL::Shape_detection::Region_growing<Point_vector,Neighbor_query,Region_type>::Region_growing': no overloaded function takes 3 arguments
C:\Users\akish\Documents\City3D\code\method\point_set_region_growing.cpp(263): error C2672: 'CGAL::Shape_detection::Region_growing<Point_vector,Neighbor_query,Region_type>::unassigned_items': no matching overloaded function found
C:\Users\akish\Documents\City3D\code\method\point_set_region_growing.cpp(263): error C2780: 'ItemOutputIterator CGAL::Shape_detection::Region_growing<Point_vector,Neighbor_query,Region_type>::unassigned_items(const InputRange &,ItemOutputIterator,ItemMap) const': expects 3 arguments - 1 provided
C:\Users\akish\Documents\vcpkg\installed\x64-windows\include\CGAL/Shape_detection/Region_growing/Region_growing.h(430): note: see declaration of 'CGAL::Shape_detection::Region_growing<Point_vector,Neighbor_query,Region_type>::unassigned_items'
NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.32.31326\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.32.31326\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
LiangliangNan commented 3 months ago

It seems you are still using the old City3D code. In your point_set_region_growing.cpp file, did you see the following lines?

// CGAL v5.6 introduced some breaking changes in the APIs for region growing algorithm
// See: https://github.com/CGAL/cgal/releases/tag/v5.6
#if CGAL_VERSION_NR >= 1050601000   // code using CGAL >= 5.6
#include <CGAL/Point_set_3.h>
#include <CGAL/Shape_detection/Region_growing/Region_growing.h>
#include <CGAL/Shape_detection/Region_growing/Point_set.h>

...

#else   // code using CGAL < 5.6, e.g., (5.5, 5.4 have been tested)
#include <CGAL/property_map.h>
#include <CGAL/Shape_detection/Region_growing.h>

...

#endif
BATspock commented 3 months ago

Yes I do see these lines in my code:

#include "point_set_region_growing.h"
#include "../model/point_set.h"
#include "../basic/logger.h"
#include <CGAL/version.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::FT FT;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;
typedef Kernel::Plane_3 Plane_3;

// CGAL v5.6 introduced some breaking changes in the APIs for region growing algorithm
// See: https://github.com/CGAL/cgal/releases/tag/v5.6
#if CGAL_VERSION_NR >= 1050601000   // code using CGAL >= 5.6
#include <CGAL/Point_set_3.h>
#include <CGAL/Shape_detection/Region_growing/Region_growing.h>
#include <CGAL/Shape_detection/Region_growing/Point_set.h>

...

#else   // code using CGAL < 5.6, e.g., (5.5, 5.4 have been tested)
#include <CGAL/property_map.h>
#include <CGAL/Shape_detection/Region_growing.h>

// Point with normal, and plane index.
typedef boost::tuple<Point, Vector, int> PNI;
typedef std::vector<PNI> Point_vector;
typedef CGAL::Nth_of_tuple_property_map<0, PNI> Point_map;
typedef CGAL::Nth_of_tuple_property_map<1, PNI> Normal_map;

...
#endif

Do I need to make any change to this?

LiangliangNan commented 3 months ago

I found the issue. I see in your CGAL version.h file the version number is 1050600900, but in City3D 1050601000 was used to differentiate v5.6 or lower. Your CGAL is a beta version of v5.6. The official release of v5.6 has a version number of 1050601000.

Anyway, I have changed the version number in City3D, so now it should work for any 5.6 versions. Please update your code and check.

The previous issue #34 should have been completely resolved.