0

I want to add a smoothing function to my C++ project so I'm trying to use the smooth_mesh() function in the CGAL library. This function requires ceres-solver to work (and glog and Eigen) so I included it in an include folder in my project.

My problem is that when I try to launch a CGAL::Polygon_mesh_processing::smooth_mesh(), it returns an error (even though everything compiles properly):

Area-based smoothing requires the Ceres Library, which is not available.

The full way I use the function is the following:

CGAL::Polygon_mesh_processing::smooth_mesh(mesh,
                       CGAL::Polygon_mesh_processing::parameters::number_of_iterations(nb_iterations)
                            .use_area_smoothing(true)
                            .use_safety_constraints(false)
                            .edge_is_constrained_map(eif));

There is a very similar question on stack but the given solution did not help me to solve my problem. The answer directed me to use #define CGAL_PMP_USE_CERES_SOLVER but even with that the error is still happening.

It also mentions Cmake but I haven't built my project nor the libraries with CMake because CGAL instructions use vcpkg so I'm guessing that it may be where the problem comes from considering most ceres doc I found use Cmake. But instructions to link ceres and cgal using Cmake are pretty hard to find and/or not very clear (and I'm also very new to Cmake so that's not helping...).

I have tried to add the library manually to my project settings (I'm using Visual Studio on Windows), add some #include linking to ceres in some cgal files but nothing seems to be working.

I'm hoping someone here has run into this problem and managed to solve it. If you can help me, thank you in advance!

Jack
  • 695
  • 10
  • 29
  • Did you add `#define CGAL_PMP_USE_CERES_SOLVER` before including any CGAL file? Because the `cerr` message is behind a `#ifndef CGAL_PMP_USE_CERES_SOLVER`. – sloriot Mar 30 '21 at 09:04
  • @sloriot when I put it before my `#include`s I get some `LINK2019` errors telling me I have `unresolved symbols` with glog, cgal, and ceres functions – Jack Mar 30 '21 at 09:16
  • Then you need to link with the libraries like `-lgmp -lmpfr -lceres -lglog` – sloriot Mar 30 '21 at 13:03
  • @sloriot I'm on windows with Visual Studio. This is a gcc command right? Do you know how I can do the same thing with Visual Studio? – Jack Mar 30 '21 at 13:35
  • If you don't know how to add libraries to link with in Visual Studio, you should probably use cmake to generate the visual studio solution and use it directly. – sloriot Mar 30 '21 at 17:28
  • @sloriot Well normally, Visual Studio does the job by itself, but considering I have added all the libraries the normal way (in the project properties : C/C++ -> Additional Include Directories for the headers, and if any libs files in the linker) I was wondering if I was missing something.. – Jack Mar 31 '21 at 07:39
  • @sloriot the problem with generating the project cmake is that I'm taking over an already big project so it's a tedious task to share with a team that is not very familiar with cmake to now compile everything with cmake. But thank you for your insight, I'll take a further look into that, if you find another solution, it's welcomed – Jack Mar 31 '21 at 07:44

0 Answers0