简体   繁体   English

如何在Mac上编译CGAL程序?

[英]How to compile CGAL programs on Mac?

OS X El Capitan 10.11.2 Installed CGAL library via macports (version 2.3.4) OS X El Capitan 10.11.2通过macports安装的CGAL库(版本2.3.4)

I have a file (/Users/Arseniy/Desktop/vec.cpp): 我有一个文件(/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;
}

Also i found headers of CGAL library (/usr/local/include/CGAL). 我也发现了CGAL库的头文件(/ usr / local / include / CGAL)。

And when i tried to compile it via g++ in terminal (g++ -0 vec vec.cpp -lCGAL -I/usr/local/include/CGAL) I see the error: "ld: library not found for -lCGAL clang: error: linker command failed with exit code 1 (use -v to see invocation). 当我尝试在终端(g ++ -0 vec vec.cpp -lCGAL -I / usr / local / include / CGAL)中通过g ++进行编译时,我看到了错误:“ ld:找不到用于-lCGAL clang的库:错误:链接器命令失败,退出代码为1(使用-v查看调用)。

I'm pretty new to gcc. 我是gcc的新手。 This problem may seem easy to you but I am here to learn. 这个问题对您来说似乎很容易,但是我在这里学习。

Thank you for your attention and your help! 感谢您的关注和帮助!

I Think Pods isn't being included in the build. 我认为Pod没有包含在构建中。

Can you check the pods root path in xcode please? 您可以在xcode中检查pods根路径吗? To do this, click "pods" > build settings > and where you see "PODS_ROOT" double click that, which show something like 为此,请单击“窗格”>“构建设置”>,然后双击“ PODS_ROOT”,显示类似

${SRCROOT}/../Pods $ {SRCROOT} /../ Pods

If everything is fine, the issue will be pods isn't being installed, run pods install ( pod install) For further reference use this link http://www.binpress.com/tutorial/cocoapods-dependancy-management-for-xcode/139 如果一切正常,则问题可能是未安装Pod,请运行pods install(pod install)以获取更多参考,请使用此链接http://www.binpress.com/tutorial/cocoapods-dependency-management-for-xcode / 139

Sorry If this Doesn't Solves your problem. 对不起,如果这样不能解决您的问题。

You need to provide the linker the path to the CGAL library using the -L option. 您需要使用-L选项为链接器提供CGAL库的路径。 You are also probably missing the -frounding-math flag. 您可能还缺少-frounding-math标志。 CGAL recommends to use cmake. CGAL建议使用cmake。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM