CGAL: How can I successfully compile and link CGAL examples (on Mac OS X 10.9 Mavericks)
Asked Answered
R

1

0

I found the CGAL examples not to compile under Mac OS X 10.9 (Mavericks). You can compile the main CGAL 4.3 library successfully and also link with it, but when using certain types of the library, I am receiving errors as shown below.

Specifically, I was interested in using the example Surface_reconstruction_points_3, which I tried to build initially, receiving this error:

Linking CXX executable poisson_reconstruction
Undefined symbols for architecture x86_64:
  "CGAL::File_writer_OFF::write_header(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, unsigned long, unsigned long, unsigned long, bool)", referenced from:
      void CGAL::generic_print_polyhedron<CGAL::Polyhedron_3<CGAL::Epick, CGAL::Polyhedron_items_3, CGAL::HalfedgeDS_default, std::__1::allocator<int> >, CGAL::File_writer_OFF>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, CGAL::Polyhedron_3<CGAL::Epick, CGAL::Polyhedron_items_3, CGAL::HalfedgeDS_default, std::__1::allocator<int> > const&, CGAL::File_writer_OFF&) in poisson_reconstruction.cpp.o
  "CGAL::is_binary(std::__1::basic_ios<char, std::__1::char_traits<char> >&)", referenced from:
      _main in poisson_reconstruction.cpp.o
  "CGAL::is_pretty(std::__1::basic_ios<char, std::__1::char_traits<char> >&)", referenced from:
      _main in poisson_reconstruction.cpp.o
  "CGAL::operator>>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, CGAL::File_header_OFF&)", referenced from:
      CGAL::Polyhedron_scan_OFF<CGAL::HalfedgeDS_default<CGAL::Epick, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::__1::allocator<int> > >::operator()(CGAL::HalfedgeDS_default<CGAL::Epick, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::__1::allocator<int> >&) in poisson_reconstruction.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [poisson_reconstruction] Error 1
make[1]: *** [CMakeFiles/poisson_reconstruction.dir/all] Error 2
make: *** [all] Error 2

To get very particular I was actually interested in the function CGAL::make_normal_of_point_with_normal_pmap and build a test case, just to try and use it. However, I receive an error when compiling this code (below).

#include <stdio.h>
#include <vector>

#include <CGAL/trace.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Surface_mesh_default_criteria_3.h>
#include <CGAL/Surface_mesh_default_triangulation_3.h>
#include <CGAL/make_surface_mesh.h>
#include <CGAL/Implicit_surface_3.h>
#include <CGAL/IO/output_surface_facets_to_polyhedron.h>
#include <CGAL/Poisson_reconstruction_function.h>
#include <CGAL/Point_with_normal_3.h>
#include <CGAL/property_map.h>
#include <CGAL/compute_average_spacing.h>
#include <CGAL/Gray_level_image_3.h>

#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/Complex_2_in_triangulation_3_file_writer.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::Sphere_3 Sphere;

typedef CGAL::Point_with_normal_3<Kernel> Point_with_normal;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef CGAL::Poisson_reconstruction_function<Kernel> Poisson_reconstruction_function;
typedef CGAL::Surface_mesh_default_triangulation_3 STr;
typedef CGAL::Surface_mesh_complex_2_in_triangulation_3<STr> C2t3;
typedef CGAL::Implicit_surface_3<Kernel, Poisson_reconstruction_function> Surface_3;

typedef STr::Geom_traits STrGT;
typedef FT (*Function)(Point);
typedef CGAL::Implicit_surface_3<STrGT, Function> ImplSurface;
typedef CGAL::Gray_level_image_3<FT, Point> Gray_level_image;
typedef CGAL::Implicit_surface_3<STrGT, Gray_level_image> Gray_level_surface;

FT sphere_function (Point p) {
  const FT x2=p.x()*p.x(), y2=p.y()*p.y(), z2=p.z()*p.z();
  return x2+y2+z2-100;
}


int main(void)
{
    printf("Hello, world!\n");


    std::vector<Point_with_normal> points;
    for (double d=0.0; d<10.0; d+=1.0)
    {
        Point_with_normal p( 0.0, 1.0*(d), 1.0*(d*d), Vector(0.0, 1.0, 0.0) );
        points.push_back(p);
    }

    Poisson_reconstruction_function function(points.begin(), points.end(),
                                             CGAL::make_normal_of_point_with_normal_pmap(points.begin()) );

    return 0;
}

And the corresponding error message:

[100%] Building CXX object CMakeFiles/cgal_test.dir/cgal_test.cpp.o
/usr/bin/c++   -DCGAL_USE_GMP -DCGAL_USE_MPFR -DWITH_CGAL -O3 -DNDEBUG -isystem /usr/local/include -I/Users/chris/dev/intern/test/cgal_testing/build -I/usr/local/Cellar/cgal/4.3/include    -o CMakeFiles/cgal_test.dir/cgal_test.cpp.o -c /Users/chris/dev/intern/test/cgal_testing/cgal_test.cpp
In file included from /Users/chris/dev/intern/test/cgal_testing/cgal_test.cpp:5:
In file included from /usr/local/Cellar/cgal/4.3/include/CGAL/Exact_predicates_inexact_constructions_kernel.h:28:
In file included from /usr/local/Cellar/cgal/4.3/include/CGAL/Simple_cartesian.h:28:
In file included from /usr/local/Cellar/cgal/4.3/include/CGAL/Cartesian/Cartesian_base.h:28:
In file included from /usr/local/Cellar/cgal/4.3/include/CGAL/basic.h:46:
In file included from /usr/local/Cellar/cgal/4.3/include/CGAL/kernel_basic.h:34:
/usr/local/Cellar/cgal/4.3/include/CGAL/Kernel_traits.h:33:23: error: no type named 'R' in
      'std::__1::__wrap_iter<CGAL::Point_with_normal_3<CGAL::Epick> *>'
  typedef typename T::R Kernel;
          ~~~~~~~~~~~~^
/usr/local/Cellar/cgal/4.3/include/CGAL/Point_with_normal_3.h:169:18: note: in instantiation of template class
      'CGAL::Kernel_traits<std::__1::__wrap_iter<CGAL::Point_with_normal_3<CGAL::Epick> *> >' requested here
  typename CGAL::Kernel_traits<Point_with_normal>::Kernel>
                 ^
/usr/local/Cellar/cgal/4.3/include/CGAL/Point_with_normal_3.h:170:3: note: while substituting deduced template arguments into function template
      'make_normal_of_point_with_normal_pmap' [with Point_with_normal = std::__1::__wrap_iter<CGAL::Point_with_normal_3<CGAL::Epick> *>]
  make_normal_of_point_with_normal_pmap(Point_with_normal)
  ^
/Users/chris/dev/intern/test/cgal_testing/cgal_test.cpp:60:13: error: no matching function for call to 'make_normal_of_point_with_normal_pmap'
                                                                                         CGAL::make_normal_of_point_with_normal_pmap(points.begin()) );
                                                                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/cgal/4.3/include/CGAL/Point_with_normal_3.h:170:3: note: candidate template ignored: substitution failure [with Point_with_normal =
      std::__1::__wrap_iter<CGAL::Point_with_normal_3<CGAL::Epick> *>]
  make_normal_of_point_with_normal_pmap(Point_with_normal)
  ^
2 errors generated.
make[2]: *** [CMakeFiles/cgal_test.dir/cgal_test.cpp.o] Error 1
make[1]: *** [CMakeFiles/cgal_test.dir/all] Error 2
make: *** [all] Error 2

As somewhat expected, the standard way of building all examples triggers errors as well (here I tried to build all CGAL examples). To get there, I used cmake to build the CGAL 4.3 library from source and enable WITH_examples in the settings. When compiling I called make and make examples, which resulted in this error:

    [ 15%] Building CXX object examples/Segment_Delaunay_graph_2/CMakeFiles/sdg-info-set.dir/sdg-info-set.cpp.o
Linking CXX executable Compute_Ridges_Umbilics
Undefined symbols for architecture x86_64:
  "boost::program_options::to_internal(std::string const&)", referenced from:
      std::vector<std::string, std::allocator<std::string> > boost::program_options::to_internal<std::string>(std::vector<std::string, std::allocator<std::string> > const&) in Compute_Ridges_Umbilics.cpp.o
  "boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)", referenced from:
      _main in Compute_Ridges_Umbilics.cpp.o
  "boost::program_options::invalid_option_value::invalid_option_value(std::string const&)", referenced from:
      void boost::program_options::validate<double, char>(boost::any&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, double*, long) in Compute_Ridges_Umbilics.cpp.o
      void boost::program_options::validate<unsigned int, char>(boost::any&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, unsigned int*, long) in Compute_Ridges_Umbilics.cpp.o
  "boost::program_options::error_with_option_name::error_with_option_name(std::string const&, std::string const&, std::string const&, int)", referenced from:
      std::basic_string<char, std::char_traits<char>, std::allocator<char> > const& boost::program_options::validators::get_single_string<char>(std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, bool) in Compute_Ridges_Umbilics.cpp.o
  "boost::program_options::detail::cmdline::set_additional_parser(boost::function1<std::pair<std::string, std::string>, std::string const&>)", referenced from:
      boost::program_options::basic_command_line_parser<char>::extra_parser(boost::function1<std::pair<std::string, std::string>, std::string const&>) in Compute_Ridges_Umbilics.cpp.o
  "boost::program_options::detail::cmdline::cmdline(std::vector<std::string, std::allocator<std::string> > const&)", referenced from:
      boost::program_options::basic_command_line_parser<char>::basic_command_line_parser(int, char const* const*) in Compute_Ridges_Umbilics.cpp.o
  "boost::program_options::validate(boost::any&, std::vector<std::string, std::allocator<std::string> > const&, std::string*, int)", referenced from:
      boost::program_options::typed_value<std::string, char>::xparse(boost::any&, std::vector<std::string, std::allocator<std::string> > const&) const in Compute_Ridges_Umbilics.cpp.o
  "boost::program_options::validate(boost::any&, std::vector<std::string, std::allocator<std::string> > const&, bool*, int)", referenced from:
      boost::program_options::typed_value<bool, char>::xparse(boost::any&, std::vector<std::string, std::allocator<std::string> > const&) const in Compute_Ridges_Umbilics.cpp.o
  "boost::program_options::operator<<(std::ostream&, boost::program_options::options_description const&)", referenced from:
      _main in Compute_Ridges_Umbilics.cpp.o
  "boost::program_options::error_with_option_name::substitute_placeholders(std::string const&) const", referenced from:
      vtable for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::invalid_option_value> > in Compute_Ridges_Umbilics.cpp.o
      vtable for boost::exception_detail::error_info_injector<boost::program_options::invalid_option_value> in Compute_Ridges_Umbilics.cpp.o
      vtable for boost::program_options::invalid_option_value in Compute_Ridges_Umbilics.cpp.o
      vtable for boost::program_options::validation_error in Compute_Ridges_Umbilics.cpp.o
      vtable for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::validation_error> > in Compute_Ridges_Umbilics.cpp.o
      vtable for boost::exception_detail::error_info_injector<boost::program_options::validation_error> in Compute_Ridges_Umbilics.cpp.o
  "boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&, std::vector<std::string, std::allocator<std::string> > const&, bool) const", referenced from:
      vtable for boost::program_options::typed_value<bool, char> in Compute_Ridges_Umbilics.cpp.o
      vtable for boost::program_options::typed_value<double, char> in Compute_Ridges_Umbilics.cpp.o
      vtable for boost::program_options::typed_value<unsigned int, char> in Compute_Ridges_Umbilics.cpp.o
      vtable for boost::program_options::typed_value<std::string, char> in Compute_Ridges_Umbilics.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [examples/Ridges_3/Compute_Ridges_Umbilics] Error 1
make[2]: *** [examples/Ridges_3/CMakeFiles/Compute_Ridges_Umbilics.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....

In the end, if you have any idea how to get the make_normal_of_point_with_normal_pmap function to work again, that would be magnificent. I do not really need to build all examples, but would like to use that part of CGAL again. Thanks!

Rooster answered 30/10, 2013 at 17:1 Comment(2)
Are you using the same compiler for compiling the library and the example? I guess you are using the CMakeLists provided with the lib?Circumsolar
yes, I am using the provided CMakeLists and did use the same compiler (g++ v4.7) - although I am not sure how boost was compiled and might try to re-install that from scratchRooster
L
1

I'm not completely au-fait with CGAL, but I would hazard a guess that you've got some of the code compiled using libc++, and some of the code compiled with libstdc++.

Lancelancelet answered 30/10, 2013 at 17:50 Comment(1)
I think you are on to something here - it seems OS 10.9 wants to link with libc++ by default (mathematica.stackexchange.com/questions/34692/…). I usually build everything with libstdc++, but since I use homebrew to install boost, it is a pre-build (Mavericks) version linked with libc++ ...Rooster

© 2022 - 2024 — McMap. All rights reserved.