环境配置 | win10下配置cgal+vs2017

环境配置 | win10下配置cgal+vs2017,第1张

目录

1.CGAL和相关库的下载

2.安装boost并配置环境变量

3.给vs2017配置CGAL库

3.1 添加包含目录

3.2 添加库目录

3.3 添加依赖项

4.运行测试程序

参考文章

1.CGAL和相关库的下载

进入https://github.com/CGAL/cgal/releases

下载这两个压缩包

分别解压缩以后,进行如下移动

选择直接替换

2.安装boost并配置环境变量

进入https://sourceforge.net/projects/boost/files/boost-binaries/1.71.0/boost_1_71_0-msvc-14.1-64.exe/download

下载二进制文件并运行

记住安装路径C:\Software\boost_1_71_0

接下来需要配置2个普通环境变量,并将一个路径添加到Path

第1个普通环境变量

 BOOST_LIBRARYDIR   C:\Software\boost_1_71_0\lib64-msvc-14.1

*** 作如图

 第2个普通环境变量

BOOST_INCLUDEDIR C:\Software\boost_1_71_0

接着将上述第1个路径添加到Path变量后(此处过程可以自己检索,不再赘述)

3.给vs2017配置CGAL库

共计3步:添加包含目录、添加库目录、添加依赖项。

在上述三步之前先新建一个项目,进入属性管理器

选择“添加新项目属性表”(此后可以复用这个属性表)

 修改属性表名称为cgal_5.4

双击刚刚建好的属性表

3.1 添加包含目录

依次加入以下3个路径

3.2 添加库目录

 依次加入以下2个路径

3.3 添加依赖项

主要指这两个lib文件

找到

复制2个.lib文件

 

 

4.运行测试程序
#include 
#include 
#include 
#include 
#include 
#include 
typedef CGAL::Simple_cartesian K;
typedef K::Point_2 Point_d;
typedef CGAL::Search_traits_2 TreeTraits;
typedef CGAL::Orthogonal_k_neighbor_search Neighbor_search;
typedef Neighbor_search::Tree Tree;
int main()
{
	const unsigned int N = 1;
	std::list points;
	points.push_back(Point_d(0, 0));
	Tree tree(points.begin(), points.end());
	// Initialize the search structure, and search all N points
	Point_d query(0, 0);
	Neighbor_search search(tree, query, N);
	// report the N nearest neighbors and their distance
   // This should sort all N points by increasing distance from origin
	for (Neighbor_search::iterator it = search.begin(); it != search.end(); ++it)
		std::cout << it->first << " " << std::sqrt(it->second) << std::endl;
	return 0;
}

 若上述步骤都正确,则不会报错;若报错,可以回过头检查一下。

 还有就是运行时注意这两个地方保持一致

参考文章

https://doc.cgal.org/latest/Manual/windows.html#title8

https://blog.csdn.net/weixin_46098577/article/details/122609078

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1325853.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-12
下一篇 2022-06-12

发表评论

登录后才能评论

评论列表(0条)

保存