由于某种原因,Combinatorial_map对象在被调用后会导致分段错误。
例如(来自CGAL示例):
#include <CGAL/Combinatorial_map.h>
#include <CGAL/Combinatorial_map_constructors.h>
#include <iostream>
#include <cstdlib>
typedef CGAL::Combinatorial_map<3> CMap_3;
typedef CMap_3::Dart_const_handle Dart_const_handle;
int main()
{
CMap_3 cm;
// Create two tetrahedra.
Dart_const_handle dh1 = CGAL::make_combinatorial_tetrahedron(cm);
Dart_const_handle dh2 = CGAL::make_combinatorial_tetrahedron(cm);
// Display the combinatorial map characteristics.
cm.display_characteristics(std::cout);
return EXIT_SUCCESS;
}
结果分段错误:11&#39;,同时评论cm.display_characteristics(std::cout);
行会导致编译成功。
类似地:
#include <CGAL/Linear_cell_complex.h>
#include <CGAL/Linear_cell_complex_operations.h>
#include <CGAL/IO/Geomview_stream.h>
#include <iostream>
#include <algorithm>
typedef CGAL::Linear_cell_complex<3> LCC3;
typedef LCC3::Dart_handle DartHandle;
typedef LCC3::Point Point;
typedef LCC3::FT FT;
typedef CGAL::Geomview_stream GVS;
int main(){
LCC3 lcc;
DartHandle d1 = lcc.make_tetrahedron( Point(-1,0,0), Point(0,2,0), Point(1,0,0), Point(1,1,2));
return 0;
}
分段错误的结果,可以通过删除DartHandle d1 = lcc.make_tetrahedron( Point(-1,0,0), Point(0,2,0), Point(1,0,0), Point(1,1,2));
行来解决。
我使用Mac OS 10.10.3并按如下方式编译我的文件:
cgal_create_CMakeList
cmake -DCGAL_DIR=/usr/local/Cellar/cgal/4.6/ .
make
当我通过以下方式更改为GNU g ++编译器时
cmake -DCGAL_DIR=/usr/local/Cellar/cgal/4.6/ -DCMAKE_CXX_COMPILER:FILEPATH=g++-5 -DCMAKE_C_COMPILER:FILEPATH=gcc-5 .
Geomview流停止工作,因此以下代码:
#include <CGAL/Linear_cell_complex.h>
#include <CGAL/Linear_cell_complex_operations.h>
#include <CGAL/IO/Geomview_stream.h>
#include <iostream>
#include <algorithm>
typedef CGAL::Linear_cell_complex<3> LCC3;
typedef LCC3::Dart_handle DartHandle;
typedef LCC3::Point Point;
typedef LCC3::FT FT;
typedef CGAL::Geomview_stream GVS;
int main(){
GVS gvs( CGAL::Bbox_3(-10, -10, -10, 120, 60, 60) );
gvs.set_line_width(4);
gvs.set_bg_color(CGAL::Color(0,200,200));
gvs.set_vertex_radius(20);
gvs << CGAL::BLUE;
gvs << Point(0,0,0);
std::cout << "Enter a key to finish" << std::endl;
char ch;
std::cin >> ch;
return 0;
}
结果:
Undefined symbols for architecture x86_64:
"CGAL::Geomview_stream::get_new_id(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
void CGAL::output_point<double>(CGAL::Geomview_stream&, double const&, double const&, double const&) in cell_complex.cpp.o
"CGAL::Geomview_stream::operator<<(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
void CGAL::output_point<double>(CGAL::Geomview_stream&, double const&, double const&, double const&) in cell_complex.cpp.o
但是使用AppleClang进行编译。
答案 0 :(得分:1)
我认为这是你的clang编译器中的一个错误(我的一位同事发现了类似的行为)。
你能告诉我你使用哪种编译器吗?
如果是同样的问题,在调试模式下编译时不会发生这种情况。你能试试吗?
纪尧姆