Ubuntu16上安装CGAL

2019-05-11  本文已影响0人  Cyfeng

在linux系统上安装CGAL

一、安装依赖

sudo apt-get install libboost-all-dev

sudo apt-get install libgmp-dev

sudo apt-get install libgmp3-dev

sudo apt-get install libmpfr-dev

sudo apt-get install geomview

sudo apt install freeglut3 freeglut3-dev

sudo apt-get install binutils-gold

sudo apt-get install libglew-dev

sudo apt-get install g++

sudo apt-get install mesa-common-dev

sudo apt-get install build-essential

sudo apt-get install libeigen3-dev

sudo apt-get install libtbb-dev

sudo apt-get install zlib1g-dev

sudo apt-get install libqt5svg5-dev

二、安装QT

如果有多个版本QT:

sudo gedit /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf

改成常用的那个:

/home/cyfeng/Qt5.10.1/5.10.1/gcc_64/bin

/home/cyfeng/Qt5.10.1/5.10.1/

三、安装libQGLViewer

libQGLViewer安装方法可以按照官网上的方法来安装,要用到上面安装的QT5。

四、安装CGAL

我的版本:cgal-releases-CGAL-4.13.1

其他版本:https://github.com/CGAL/cgal

unzip CGAL-4.13.1.zip

cd CGAL-4.13.1

mkdir build

cd build

cmake ..

make -j4

sudo make install

检查是否有libCGAL_Qt5.so

ls /usr/local/lib/libCGAL*

五、测试

新建Qt Widgets application项目(console application项目会报错,找不到QApplication)

修改.pro文件中QT += core gui xml opengl和添加LIBS += -lCGAL -lCGAL_Core -lgmp -lCGAL_Qt5

main.cpp(corner.off的路径自行修改)

#define CGAL_USE_BASIC_VIEWER
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/draw_polyhedron.h>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel  Kernel;
typedef CGAL::Polyhedron_3<Kernel>                       Polyhedron;
int main(int argc, char* argv[])
{
  Polyhedron P;
  std::ifstream in1((argc>1)?argv[1]:"/home/cyfeng/cgal-releases-CGAL-4.13.1/Polyhedron/examples/Polyhedron/data/corner.off");
  in1 >> P;
  CGAL::draw(P);
  return EXIT_SUCCESS;
}

参考:

https://www.jianshu.com/p/4e3d69c77a4c

https://blog.csdn.net/dumpdoctorwang/article/details/81163702

上一篇下一篇

猜你喜欢

热点阅读