一、安装boost
下载链接:https://sourceforge.net/projects/boost/files/boost-binaries/,14.2对应的是vs2019,我下载的是boost1_80_0-msvc-14.2-64.exe,然后傻瓜式安装。在环境变量中新建项:
BOOST_LIBRARYDIR =E:\DEV\boost\boost_1_80_0\lib64-msvc-14.2
BOOST_INCLUDEDIR =E:\DEV\boost\boost_1_80_0
二、安装CGAL
我下载的是CGAL-5.0.-Setup.exe,链接:Release CGAL-5.0.4 · CGAL/cgal · GitHub,然后傻瓜式安装,安装完成时会有一个提醒,然后我们手动将E:\DEV\CGAL\auxiliary\gmp\lib添加到系统环境变量中。
三、在VS2019中配置CGAL项目
打开项目属性页,在VC++目录中的包含目录中添加:E:\DEV\boost\boost_1_80_0,E:\DEV\CGAL\include,E:\DEV\CGAL\auxiliary\gmp\include;添加库目录:E:\DEV\CGAL\auxiliary\gmp\lib;在链接器>>输入中添加依赖项:E:\DEV\CGAL\auxiliary\gmp\lib\libgmp-10.lib,E:\DEV\CGAL\auxiliary\gmp\lib\libmpfr-4.lib。
将C:\Mysoft\CGAL\auxiliary\gmp\lib中的libgmp-10.dll和libmpfr-4.dll复制到C:\Windows\System32文件夹中。
注意:debug选择的是x64而不是x86。
测试代码:
#include <iostream>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <sstream>
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
int main()
{
Point_2 p(0, 0.3), q, r(2, 0.9);
{
q = Point_2(1, 0.6);
std::cout << (CGAL::collinear(p, q, r) ? "collinear\n" : "not collinear\n");
}
{
std::istringstream input("0 0.3 1 0.6 2 0.9");
input >> p >> q >> r;
std::cout << (CGAL::collinear(p, q, r) ? "collinear\n" : "not collinear\n");
}
{
q = CGAL::midpoint(p, r);
std::cout << (CGAL::collinear(p, q, r) ? "collinear\n" : "not collinear\n");
}
return 0;
}
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/convex_hull_2.h>
#include <vector>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point_2;
typedef std::vector<Point_2> Points;
int main()
{
Points points, result;
points.push_back(Point_2(0,0));
points.push_back(Point_2(10,0));
points.push_back(Point_2(10,10));
points.push_back(Point_2(6,5));
points.push_back(Point_2(4,1));
CGAL::convex_hull_2( points.begin(), points.end(), std::back_inserter(result) );
std::cout << result.size() << " points on the convex hull" << std::endl;
return 0;
}
参考文献:
【1】(115条消息) C++,VS2019安装和配置CGAL,GDAL,Boost_c++gdal19安装_西北码农的博客-CSDN博客