在C++控制台项目中调用CGAL
CGAL的安装教程详细:https://www.cnblogs.com/ShawBlack/p/17000087.html
对于如何在项目中调用CGAL,跟着下面的流程走就好
1.用VS新建C++控制台项目
2.配置项目依赖项
(1).选中项目右键-属性,进入项目属性页。
(2).C/C++ - 常规 -附加包含目录:
-
- C:\dev\CGAL-5.2.1\include
- C:\dev\CGAL-5.2.1\auxiliary\gmp\include
- C:\local\boost_1_71_0
(3).链接器->输入->附加依赖项:
-
- C:\dev\CGAL-5.2.1\auxiliary\gmp\lib\libgmp-10.lib
- C:\dev\CGAL-5.2.1\auxiliary\gmp\lib\libmpfr-4.lib
3.拷贝下面代码
#include <iostream> #include <CGAL/Simple_cartesian.h> typedef CGAL::Simple_cartesian<double> Kernel; typedef Kernel::Point_2 Point_2; typedef Kernel::Segment_2 Segment_2; int main() { Point_2 p(1,1), q(10,10); std::cout << "p = " << p << std::endl; std::cout << "q = " << q.x() << " " << q.y() << std::endl; std::cout << "sqdist(p,q) = " << CGAL::squared_distance(p,q) << std::endl; Segment_2 s(p,q); Point_2 m(5, 9); std::cout << "m = " << m << std::endl; std::cout << "sqdist(Segment_2(p,q), m) = " << CGAL::squared_distance(s,m) << std::endl; std::cout << "p, q, and m "; switch (CGAL::orientation(p,q,m)){ case CGAL::COLLINEAR: std::cout << "are collinear\n"; break; case CGAL::LEFT_TURN: std::cout << "make a left turn\n"; break; case CGAL::RIGHT_TURN: std::cout << "make a right turn\n"; break; } std::cout << " midpoint(p,q) = " << CGAL::midpoint(p,q) << std::endl; return 0; }
4.编译生成项目
5.enjoy~
参考:
(63条消息) cgal 5.X 基于windows安装 配置 使用_宛如一个zz蛤的博客-CSDN博客_cgal安装windows
(63条消息) C++,VS2019安装和配置CGAL,GDAL,Boost_西北码农的博客-CSDN博客_c++ cgal安装