【发布时间】:2015-11-18 06:58:24
【问题描述】:
OS X El Capitan 10.11.2 通过 macports 安装 CGAL 库(版本 2.3.4)
我有一个文件(/Users/Arseniy/Desktop/vec.cpp):
#include <iostream>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/convex_hull_2.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point_2;
int main()
{
Point_2 points[5] = { Point_2(0,0), Point_2(10,0), Point_2(10,10), Point_2(6,5), Point_2(4,1) };
Point_2 result[5];
Point_2 *ptr = CGAL::convex_hull_2( points, points+5, result );
std::cout << ptr - result << " points on the convex hull:" << std::endl;
for(int i = 0; i < ptr - result; i++){
std::cout << result[i] << std::endl;
}
return 0;
}
我还找到了 CGAL 库 (/usr/local/include/CGAL) 的标头。
当我尝试在终端中通过 g++ 编译它时 (g++ -0 vec vec.cpp -lCGAL -I/usr/local/include/CGAL) 我看到了错误: “ld:找不到-lCGAL的库 clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)。
我对 gcc 很陌生。这个问题对你来说似乎很容易,但我是来学习的。
感谢您的关注和帮助!
【问题讨论】:
-
所以,我用 CGAL 库的 h 文件将文件 vec.cpp 替换到(/usr/local/include/CGAL)文件夹中。现在 gcc 只向我发送一个错误:vec.cpp:2:10: fatal error: 'CGAL/Exact_predicates_inexact_constructions_kernel.h' file not found #include
但这个文件确实存在。 ^ 产生 1 个错误。