gpt4 book ai didi

c++ - CGAL:如何成功编译和链接 CGAL 示例(在 Mac OS X 10.9 Mavericks 上)

转载 作者:行者123 更新时间:2023-11-28 07:19:40 25 4
gpt4 key购买 nike

我发现 CGAL 示例无法在 Mac OS X 10.9 (Mavericks) 下编译。您可以成功编译主要的 CGAL 4.3 库并链接它,但是当使用某些类型的库时,我会收到如下所示的错误。

具体来说,我对使用示例 Surface_reconstruction_points_3 很感兴趣,我最初尝试构建它,但收到此错误:

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

具体来说,我实际上对函数 CGAL::make_normal_of_point_with_normal_pmap 很感兴趣,并构建了一个测试用例,只是为了尝试使用它。但是,我在编译此代码(如下)时收到错误消息。

#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;
}

以及相应的错误信息:

[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

正如预期的那样,构建所有示例的标准方法也会触发错误(此处我尝试构建所有 CGAL 示例)。为此,我使用 cmake 从源代码构建了 CGAL 4.3 库,并在设置中启用了 WITH_examples。编译时我调用了 makemake examples,这导致了这个错误:

    [ 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....

最后,如果您知道如何让 make_normal_of_point_with_normal_pmap 函数再次运行,那就太棒了。我真的不需要构建所有示例,但想再次使用 CGAL 的那部分。谢谢!

最佳答案

我对 CGAL 不是很熟悉,但我敢猜测您已经使用 libc++ 编译了一些代码,还有一些使用 libstdc++ 编译的代码。

关于c++ - CGAL:如何成功编译和链接 CGAL 示例(在 Mac OS X 10.9 Mavericks 上),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19689245/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com