2015-06-16 52 views
0

由於某種原因,Combinatorial_map對象在被調用後會導致分段錯誤。CGAL組合映射和Geomview

例如(來自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',而在評論編譯成功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編譯。

回答

1

我認爲這是你的clang編譯器中的一個bug(我的一個同事觀察到了類似的行爲)。

你能告訴我你使用哪個編譯器嗎?

而且,如果它是相同的問題,那麼當您在調試模式下編譯時不會發生這種情況。你可以試試嗎?

Guillaume

+0

謝謝,我認爲這是一個編譯器問題。我改爲GNU GCC,一切正常。 – user1513100

+0

雖然更改編譯器Geomview_stream停止工作後。 – user1513100

+0

如果更改編譯器,則需要使用使用新編譯器編譯的所有庫(cgal,但也包括其他必需的庫)。 – gdamiand