如何在Mac上编译CGAL程序

How to compile CGAL programs on Mac?

本文关键字:编译 CGAL 程序 Mac      更新时间:2023-10-16

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的新手。这个问题对你来说可能很容易,但我是来学习的。

感谢您的关注和帮助!

我认为构建中没有包含Pods。

你能在xcode中检查一下pods的根路径吗?要做到这一点,请单击"pods">构建设置>,在您看到"pods_ROOT"的地方双击它,它会显示类似的内容

${SRCROOT}//吊舱

如果一切正常,问题将是没有安装pod,请运行pod install(pod install)如需进一步参考,请使用此链接http://www.binpress.com/tutorial/cocoapods-dependancy-management-for-xcode/139

抱歉,如果这不能解决你的问题。

您需要使用-L选项为链接器提供CGAL库的路径。你可能也错过了数学标志。CGAL建议使用cmake。