【问题标题】:How to compile CGAL programs on Mac?如何在 Mac 上编译 CGAL 程序?
【发布时间】: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 个错误。

标签: c++ macos gcc g++ cgal


【解决方案1】:

我认为 Pods 未包含在构建中。

您能检查一下 xcode 中的 pod 根路径吗?为此,请单击“pods”>构建设置>并在您看到“PODS_ROOT”的地方双击它,显示类似

${SRCROOT}/../Pods

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

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

【讨论】:

    【解决方案2】:

    您需要使用 -L 选项为链接器提供 CGAL 库的路径。您也可能缺少 -frounding-math 标志。 CGAL 推荐使用 cmake。

    【讨论】:

      猜你喜欢
      • 2014-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-30
      • 2023-03-27
      • 2014-07-19
      • 2018-08-04
      • 1970-01-01
      相关资源
      最近更新 更多