Я только что установил CGAL с Brew в системе Mac. Теперь мне интересно попробовать это на простом и минимальном примере. Как я могу скомпилировать его с g ++?
Я хочу скомпилировать этот пример файла с:
gcc namefile.cpp -lCGAL -I/usr/local/include/CGAL
и я получаю много ошибок … (я думаю, слишком много, чтобы вставить это здесь)
в качестве примера файла, который я использую
File: examples/Arrangement_on_surface_2/sweep_line.cpp#include <CGAL/Cartesian.h>
#include <CGAL/MP_Float.h>
#include <CGAL/Quotient.h>
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Sweep_line_2_algorithms.h>
#include <list>
typedef CGAL::Quotient<CGAL::MP_Float> NT;
typedef CGAL::Cartesian<NT> Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
typedef Traits_2::Curve_2 Segment_2;
int main()
{
// Construct the input segments.
Segment_2 segments[] = {Segment_2 (Point_2 (1, 5), Point_2 (8, 5)),
Segment_2 (Point_2 (1, 1), Point_2 (8, 8)),
Segment_2 (Point_2 (3, 1), Point_2 (3, 8)),
Segment_2 (Point_2 (8, 5), Point_2 (8, 8))};
// Compute all intersection points.
std::list<Point_2> pts;
CGAL::compute_intersection_points (segments, segments + 4,
std::back_inserter (pts));
// Print the result.
std::cout << "Found " << pts.size() << " intersection points: " << std::endl;
std::copy (pts.begin(), pts.end(),
std::ostream_iterator<Point_2>(std::cout, "\n"));
// Compute the non-intersecting sub-segments induced by the input segments.
std::list<Segment_2> sub_segs;
CGAL::compute_subcurves(segments, segments + 4, std::back_inserter(sub_segs));
std::cout << "Found " << sub_segs.size()
<< " interior-disjoint sub-segments." << std::endl;
CGAL_assertion (CGAL::do_curves_intersect (segments, segments + 4));
return 0;
}
>>> g++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
>>> g++ sweep_line.cpp
In file included from /usr/local/include/CGAL/Bbox_2.h:31,
from /usr/local/include/CGAL/basic_classes.h:31,
from /usr/local/include/CGAL/Cartesian/Cartesian_base.h:29,
from /usr/local/include/CGAL/Cartesian.h:28,
from sweep_line.cpp:4:
/usr/local/include/CGAL/array.h:81: error: expected nested-name-specifier before '...' token
/usr/local/include/CGAL/array.h:81: error: expected '>' before '...' token
/usr/local/include/CGAL/array.h:83: error: template argument 2 is invalid
/usr/local/include/CGAL/array.h:84: error: expected ',' or '...' before '&' token
/usr/local/include/CGAL/array.h: In function 'int CGAL::make_array(const T&, int)':
/usr/local/include/CGAL/array.h:86: error: template argument 2 is invalid
/usr/local/include/CGAL/array.h:86: error: invalid type in declaration before '=' token
/usr/local/include/CGAL/array.h:86: error: 'args' was not declared in this scope
/usr/local/include/CGAL/array.h:86: error: expected `}' before '...' token
/usr/local/include/CGAL/array.h:86: error: expected `}' before '...' token
/usr/local/include/CGAL/array.h:86: error: expected ',' or ';' before '...' token
/usr/local/include/CGAL/array.h: At global scope:
/usr/local/include/CGAL/array.h:87: error: expected unqualified-id before 'return'
/usr/local/include/CGAL/array.h:88: error: expected declaration before '}' token
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.>>>g++ sweep_line.cpp -lCGAL -I/usr/local/include/CGAL
In file included from /usr/local/include/CGAL/gmpxx_coercion_traits.h:35,
from /usr/local/include/CGAL/mpz_class.h:29,
from /usr/local/include/CGAL/gmpxx.h:47,
from /usr/local/include/CGAL/is_convertible.h:28,
from /usr/local/include/CGAL/Rational_traits.h:31,
from /usr/local/include/CGAL/number_type_basic.h:65,
from /usr/local/include/CGAL/basic.h:36,
from /usr/local/include/CGAL/Cartesian/Cartesian_base.h:28,
from /usr/local/include/CGAL/Cartesian.h:28,
from sweep_line.cpp:4:
/usr/local/include/mpfr.h:181: error: expected ';' before '*' token
/usr/local/include/mpfr.h:279: error: expected constructor, destructor, or type conversion before 'const'
/usr/local/include/mpfr.h:280: error: expected constructor, destructor, or type conversion before 'const'
/usr/local/include/mpfr.h:281: error: expected constructor, destructor, or type conversion before 'int'
/usr/local/include/mpfr.h:282: error: expected constructor, destructor, or type conversion before 'int'
/usr/local/include/mpfr.h:283: error: expected constructor, destructor, or type conversion before 'int'
/usr/local/include/mpfr.h:284: error: expected constructor, destructor, or type conversion before 'const'
/usr/local/include/mpfr.h:286: error: '__GMP_DECLSPEC' does not name a type
/usr/local/include/mpfr.h:287: error: expected constructor, destructor, or type conversion before 'int'
/usr/local/include/mpfr.h:288: error: '__GMP_DECLSPEC' does not name a type
/usr/local/include/mpfr.h:289: error: '__GMP_DECLSPEC' does not name a type
/usr/local/include/mpfr.h:290: error: '__GMP_DECLSPEC' does not name a type
/usr/local/include/mpfr.h:291: error: expected constructor, destructor, or type conversion before 'int'
/usr/local/include/mpfr.h:292: error: '__GMP_DECLSPEC' does not name a type
/usr/local/include/mpfr.h:293: error: '__GMP_DECLSPEC' does not name a type
/usr/local/include/mpfr.h:295: error: expected constructor, destructor, or type conversion before 'void'
/usr/local/include/mpfr.h:296: error: '__GMP_DECLSPEC' does not name a type
/usr/local/include/mpfr.h:297: error: expected constructor, destructor, or type conversion before 'const'
/usr/local/include/mpfr.h:300: error: expected constructor, destructor, or type conversion before 'void'
/usr/local/include/mpfr.h:301: error: expected constructor, destructor, or type conversion before 'void'
/usr/local/include/mpfr.h:302: error: expected constructor, destructor, or type conversion before 'void'
/usr/local/include/mpfr.h:303: error: expected constructor, destructor, or type conversion before 'void'
/usr/local/include/mpfr.h:304: error: expected constructor, destructor, or type conversion before 'void'
У вас есть два пути:
--std=c++11
или же --std=c++0x
). CGAL_CFG_NO_CPP0X_ARRAY
, CGAL_CFG_NO_TR1_ARRAY
а также CGAL_CFG_NO_VARIADIC_TEMPLATES
, Примечание: в этом случае вам понадобится boost/array.hpp
заголовок.Вы должны использовать
-I / USR / местные / включить
вместо
-I / USR / местные / включить / CGAL