CGAL4.13配置

1. 软件环境

Visual Studio Ultimate 2013安装包

QT 5.6.2安装包

Qt-vs-addin-1.2.5安装包(Qt用于VS开发环境的菜单配置等的插件)

Boost 1.69安装包

压缩文件CGAL-4.13 (编译好的版本,链接库在文件夹的sdk目录中。可以直接解压使用,编译是依赖QT5.6.2和Boost 1.69。CGAL的其他版本也可以自己编译)

 

 安装顺序

(1)Visual Studio Ultimate 2013 傻瓜式安装

(2)QT 5.6.2傻瓜式安装

(3)Qt-vs-addin-1.2.5傻瓜式安装

(4)Boost 1.69傻瓜式安装

(4)直接解压缩文件CGAL-4.13

2. CGAL的编译

自己编译

下载CGAL的源码,安装过程需要联网下载一些类库。

安装编译步骤参考:https://doc.cgal.org/latest/Manual/windows.html#title8

 

(1)安装boost1.69

Boost is a mandatory dependency of CGAL. Binary versions of Boost are available on SourceForge. The Boost installers install both Boost headers and precompiled libraries. Please note that the CGAL project is not responsible for the files provided on this website. When CGAL 4.13 was released, the version of Boost was 1.69. A typical installation of Boost would consist of the following steps:

  • Download and run the file boost_1_69_0-msvc-XX.Y-64.exe (where XX.Y = 12.0 for VC 2013, XX.Y = 14.0 for VC 2015, XX.Y = 14.1 for 2017, XX.Y = 14.2 for VC 2019).
  • Extract the files to a new directory, e.g.c:\dev\boost_1_69_0.
  • Set the following two environment variables to point respectively to the path of the libraries and the headers
    • BOOST_LIBRARYDIR = C:\dev\boost_1_69_0\lib64-msvc-XX.Y
    • BOOST_INCLUDEDIR = C:\dev\boost_1_69_0

as this will help cmake to find Boost.

  • Add the path to the Boost dlls (C:\dev\libboost_1_69_0\lib64-msvc-XX.Y) files to the PATH environment variable.

(2)安装QT,CGAL本身不依赖于QT,但是实例程序可能需要

CGAL is a library of algorithms and data structures and as such does not depend on Qt. However, one of the examples does for visualization purposes only. Either you have Qt installed and you can fill in the requested CMake variables, or you must install it. A typical Qt installation would consist of the following steps:

  • Download and install the Qt library for open source development package for your Visual Studio version at https://www.qt.io/download/ (here is the direct link to the offline installers).
  • Add the environment variable QTDIR pointing to the place you installed Qt, e.g., C:\dev\Qt\Qt5.6.2, as this will help cmake to find Qt.
  • Add the bin directory of Qt, e.g. add C:\dev\Qt\Qt5.6.2\msvcXXXX_YY\bin to PATH, where XXXX_YY is something like vc2013_64. To avoid any conflict with another dll with the same name from another folder, add this path as the first in the list.

接下来,利用CMake最新版本3.20配置项目,注意在CMake中勾选advanced,不然好多选项看不到!慎慎!

 

 修改configure过程中产生的所有错误,configure过程中产生的所有错误必须解决,然后才能Generate成功。

(配置安装目录)

打开build文件夹中的*.sln文件,利用VS2013进行编译,编译完成后继续编译VS项目中的Install项目,完成安装。生成的开发SDK安装在D:/Program Files/CGAL文件夹中,可以单独拷贝使用。

 

 

之后VS新建VC++控制台项目或者QT应用程序,添加头文件,库目录和依赖项的类库就可以进行开发了。

3. 运行实例程序

新建VC++控制台应用程序

(注意以下配置均为debug模式,通常文件后面会加d或者-d来标注。如果是release模式,所有的boost、qt和cgal依赖文件都应选择release版本编译的lib和dll。两种模式生成的文件不能混用)

(1)       头文件目录

设置属性页-》包含库目录

 

D:\ReferenceSDK\CGAL-4.13\sdk\include

D:\ReferenceSDK\CGAL-4.13\auxiliary\gmp\include

D:\ReferenceSDK\eigen3.2.7(矩阵运算库,提供头文件,编译是直接链接,没有lib、dll)

D:\ReferenceSDK\boost_1_69_0

(2)       设置预处理器

 

 预处理宏定义:过程中遇到不少问题,不知道是不是Cpp11的影响,产生很多错误,通过增加了一些预处理宏定义解决:

CGAL_EIGEN3_ENABLED

EIGEN_NO_EIGEN2_DEPRECATED_WARNING

EIGEN2_SUPPORT

CGAL_CFG_NO_CPP0X_ARRAY

BOOST_NO_CXX11_HDR_ARRAY

_CRT_SECURE_NO_WARNINGS

_SCL_SECURE_NO_WARNINGS

(3)       库目录

 

D:\ReferenceSDK\CGAL-4.13\sdk\lib

D:\ReferenceSDK\CGAL-4.13\auxiliary\gmp\lib

D:\ReferenceSDK\boost_1_69_0\lib64-msvc-12.0

(4)       依赖项静态链接库

  

libboost_math_tr1f-vc120-mt-gd-x64-1_69.lib

libboost_math_tr1l-vc120-mt-gd-x64-1_69.lib

libboost_math_tr1-vc120-mt-gd-x64-1_69.lib

libboost_prg_exec_monitor-vc120-mt-gd-x64-1_69.lib

libboost_program_options-vc120-mt-gd-x64-1_69.lib

libboost_random-vc120-mt-gd-x64-1_69.lib

libboost_regex-vc120-mt-gd-x64-1_69.lib

libboost_serialization-vc120-mt-gd-x64-1_69.lib

libboost_system-vc120-mt-gd-x64-1_69.lib

libboost_test_exec_monitor-vc120-mt-gd-x64-1_69.lib

libboost_thread-vc120-mt-gd-x64-1_69.lib

libboost_timer-vc120-mt-gd-x64-1_69.lib

libboost_type_erasure-vc120-mt-gd-x64-1_69.lib

libboost_unit_test_framework-vc120-mt-gd-x64-1_69.lib

libboost_wave-vc120-mt-gd-x64-1_69.lib

libboost_wserialization-vc120-mt-gd-x64-1_69.lib

libgmp-10.lib

libmpfr-4.lib

CGAL_Core-vc120-mt-gd-4.13-I-900.lib

CGAL_ImageIO-vc120-mt-gd-4.13-I-900.lib

CGAL-vc120-mt-gd-4.13-I-900.lib

(5)       运行实例程序:

 1 #include "stdafx.h"
 2 
 3 #include <iostream>
 4 
 5 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
 6 
 7 #include <CGAL/convex_hull_2.h>
 8 
 9 typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
10 
11 typedef K::Point_2 Point_2;
12 
13 int main()
14 
15 {
16 
17     Point_2 points[5] = { Point_2(0, 0), Point_2(10, 0), Point_2(10, 10), Point_2(6, 5), Point_2(4, 1) };
18 
19     Point_2 result[5];
20 
21     Point_2 *ptr = CGAL::convex_hull_2(points, points + 5, result);
22 
23     std::cout << ptr - result << " points on the convex hull:" << std::endl;
24 
25     for (int i = 0; i < ptr - result; i++){
26 
27         std::cout << result[i] << std::endl;
28 
29     }
30 
31     return 0;
32 
33 }

将上面参与编译的静态链接库的dll动态库文件拷贝到debug目录

 

运行程序

 

 

posted @ 2021-03-09 14:44  太一吾鱼水  阅读(341)  评论(0编辑  收藏  举报