Macports cgal 不工作!我该如何修复它?
这是我在 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。有谁知道可能出了什么问题 这?
This is a basic example that I found on the CGAL main webpage. I am trying to compile the following:
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 }
but I get this error:
Demo gt; 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
I installed cgal using macports. Does anyone know what could be wrong with
this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实上,它看起来像是构建 CGAL 和使用 CGAL 编译时使用的编译器或编译器选项之间不匹配。可能 macports 没有帮助,我在安装 CGAL 时使用 homebrew 比 macports 更幸运。
Indeed it looks like a mismatch between compiler or compiler options used when building CGAL and compiling with CGAL. It may be that macports doesn't help, I have been luckier with homebrew than macports when installing CGAL.