1
這是我在CGAL主頁上找到的一個基本例子。我試圖編譯如下:Macports cgal不工作!我如何解決它?
1 #include <iostream>
2 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
3 #include <CGAL/convex_hull_2.h>
4
5 typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
6 typedef K::Point_2 Point_2;
7
8 int main()
9 {
10 Point_2 points[5] = { Point_2(0,0), Point_2(10,0), Point_2(10,10), Point_2(6,5), Point_2(4,1) };
11 Point_2 result[5];
12
13 Point_2 *ptr = CGAL::convex_hull_2(points, points+5, result);
14 std::cout << ptr - result << " points on the convex hull" << std::endl;
15 return 0;
16 }
,但我得到這個錯誤:
Demo $> make
[100%] Building CXX object CMakeFiles/helloworld_cgal.dir/helloworld_cgal.cpp.o
In file included from /opt/local/include/CGAL/Bbox_2.h:30,
from /opt/local/include/CGAL/basic_classes.h:30,
from /opt/local/include/CGAL/Cartesian/Cartesian_base.h:28,
from /opt/local/include/CGAL/Simple_cartesian.h:27,
from /opt/local/include/CGAL/Exact_predicates_inexact_constructions_kernel.h:27,
from /Users/carlos/Documents/Code/Demo/helloworld_cgal.cpp:2:
/opt/local/include/CGAL/array.h:81: error: expected nested-name-specifier before ‘...’ token
/opt/local/include/CGAL/array.h:81: error: expected ‘>’ before ‘...’ token
/opt/local/include/CGAL/array.h:83: error: template argument 2 is invalid
/opt/local/include/CGAL/array.h:84: error: expected ‘,’ or ‘...’ before ‘&’ token
/opt/local/include/CGAL/array.h:84: error: ISO C++ forbids declaration of ‘Args’ with no type
/opt/local/include/CGAL/array.h: In function ‘int CGAL::make_array(const T&, int)’:
/opt/local/include/CGAL/array.h:86: error: template argument 2 is invalid
/opt/local/include/CGAL/array.h:86: error: invalid type in declaration before ‘=’ token
/opt/local/include/CGAL/array.h:86: error: ‘args’ was not declared in this scope
/opt/local/include/CGAL/array.h:86: error: expected `}' before ‘...’ token
/opt/local/include/CGAL/array.h:86: error: expected `}' before ‘...’ token
/opt/local/include/CGAL/array.h:86: error: expected ‘,’ or ‘;’ before ‘...’ token
/opt/local/include/CGAL/array.h: At global scope:
/opt/local/include/CGAL/array.h:87: error: expected unqualified-id before ‘return’
/opt/local/include/CGAL/array.h:88: error: expected declaration before ‘}’ token
make[2]: *** [CMakeFiles/helloworld_cgal.dir/helloworld_cgal.cpp.o] Error 1
make[1]: *** [CMakeFiles/helloworld_cgal.dir/all] Error 2
make: *** [all] Error 2
我的MacPorts使用安裝CGAL。有沒有人知道 這可能是錯誤的?
請將您的代碼內聯,而不是在pastebin上發佈。錯誤也是一樣。 – 2012-02-07 19:34:15
對不起,我不知道它支持內聯代碼。讓我知道如果你知道如何解決它... – newDelete 2012-02-07 20:19:59
它可能是編譯器用於macport來構建CGAL不是用於編譯您的示例。你的錯誤是你的編譯器不支持variadic模板參數,而CGAL是用它們配置的。 – sloriot 2012-02-08 06:50:36