0

I'm new to C++ and CGAL, previously I worked mainly with C#.

I installed CGAL as described on https://www.cgal.org/download/windows.html and all steps finished successfully. Then I looked to a CGAL 'Hello world' (https://doc.cgal.org/latest/Manual/Kernel_23_2points_and_segment_8cpp-example.html); here I had no problem also; all the code was compiled and run propertly.

But when I tried with more complex things I got a strange issue. For example I tried to compile Skeletonization (https://doc.cgal.org/latest/Surface_mesh_skeletonization/Surface_mesh_skeletonization_2simple_mcfskel_example_8cpp-example.html); here I got a number of errors like these:

C2039 ''extract_mean_curvature_flow_skeleton'': is not a member of ''CGAL''
C2039 ''Matrix'': is not a member of ''CGAL::Default''
C2039 ''Vector'': is not a member of ''CGAL::Default''

As far as I understand it the #include lines processed without errors, all needed headers exist.

I tried to search the answer and found this: http://cgal-discuss.949826.n4.nabble.com/Problem-on-Surface-mesh-deformation-td4661042.html Unfortunately I don't be sure my case is similar and I don't know what exactly do the line #define CGAL_EIGEN3_ENABLED as recommended there.

In any case I tried to add it and got the same errors as previous if this #define inserted after #include ; in different case arise a lot of errors like this:

LNK2019 unresolved external symbol __imp___gmpq_add referenced in function "class CGAL::Gmpq __cdecl CGAL::operator+(class CGAL::Gmpq const &,class CGAL::Gmpq const &)" (??HCGAL@@YA?AVGmpq@0@AEBV10@0@Z)

I work with VS 2017, in Additional library directories I added:

$(CGAL_DIR)/lib/Debug;$(CGAL_DIR)/lib

in Additional include directories:

$(CGAL_ROOT)\include;$(CGAL_ROOT)\auxiliary\gmp\include;
$(CGAL_DIR)\include;$(BOOST_INCLUDEDIR)

maybe some needed libraries or include directories are missing here?
All the components (CGAL, boost, QT) installed in 64 bits versions as well as test project.

UPD: The question is solved!

The answer was extremely simple (please note I'm new in C++):
1. I loaded and unzip EIGEN (it need not to install); for convenience I create also EIGEN_DIR variable;
2. I added to Additional Include Directories: $(EIGEN_DIR);
3. I added before #include statements #define CGAL_EIGEN3_ENABLED;
4. I added to Additional Dependencies such libs:

$(CGAL_ROOT)\auxiliary\gmp\lib\libmpfr-4.lib
$(CGAL_ROOT)\auxiliary\gmp\lib\libgmp-10.lib

and it start to work!

  • _"f this #define inserted after #include"_ Aren't you supposed to place it ***before*** the `#include` statement? –  Jan 20 '18 at 09:08
  • to @user9212993 - Yes I think so, but as I say earlier in this case I got a lot of errors LNK2019 'unresolved external symbol'. And I have no any idea how to fix it. – Oleksandr Korniienko Jan 20 '18 at 12:17
  • After fixing the errors caused by the missing `#define`, you'll need to specify that library and where it is installed for the linker. See [here](https://stackoverflow.com/questions/12573816/how-to-fix-undefined-reference-unresolved-external-symbol-error) what are the causes for the 'unresolved external symbol' errors. –  Jan 20 '18 at 12:42
  • In Additional library directories I added $(BOOST_LYBRARYDIR) and $(CGAL_DIR)/lib; do you think I need some additional one? – Oleksandr Korniienko Jan 20 '18 at 13:19
  • Please [edit] your question to add additional information. It's not helpful in comments. And yes you obviously seem to miss something regarding the `CGAL` library. –  Jan 20 '18 at 13:22
  • Thank you for the answers, I edited the question. But it's really hard for me; I installed (and add to lib) all points described by CGAL manuals. Thus I don't know what libs CGAL needs additionally. – Oleksandr Korniienko Jan 20 '18 at 14:25
  • So besides adding the directories, did you also actually add the library references to your project? Maybe [this](https://stackoverflow.com/questions/24715864/problems-importing-libraries-to-my-c-project-how-to-fix-this) is more helpful for you. –  Jan 20 '18 at 14:53
  • There are several issues here. First about `CGAL_EIGEN3_ENABLED`, it is a macro that is supposed to be added by cmake when you configure the example and that indicates that you have eigen 3 installed on your computer. The link error indicates that libCGAL is linked with your application. Maybe you did but are using a 32bit version while compiling a 64bit application. – sloriot Jan 22 '18 at 07:27

0 Answers0