您的位置:首页 > 编程语言 > Qt开发

CGAL4.9+boost1.59+QT5.6+vs2015 64bit+windows10配置

2017-04-28 12:55 267 查看
一、配置QT,只需五部

1.下载QT,注意msvc匹配版本号和windows位数

进入http://www.qt.io/download-open-source/,选择“Qt Offline Installers”,下载“Qt 5.6.0 for Windows 64-bit (VS 2015, 836 MB)”,下载后的文件名为:qt-opensource-windows-x86-msvc2015_64-5.6.0.exe

2.把QT的bin目录,添加至环境变量的path中

C:\Qt\Qt5.6.0\5.6\msvc2015_64\bin

3. 安装VS2015支持QT的插件QTPackge
https://visualstudiogallery.msdn.microsoft.com/c89ff880-8509-47a4-a262-e4fa07168408
4.添加并设置Qt版本

打开VS,菜单栏QT5,点击Qt Options

选择“Add”添加一个项,“Name”填“msvc2015_64”,“Path”填Qt的msvc安装目录C:\Qt\Qt5.6.0\5.6\msvc2015_64

打开VS,菜单栏QT5,点击Qt Project Settings -> Properties -> Version ,选择之前添加的Qt版本 msvc2015_64

5. 新建Qt项目,配置VS项目属性表

新建->VC++->Qt5 Projects->Qt Application,新建一个Qt项目

按照之前配置属性的方式

VC++包含目录配置为:  C:\Qt\Qt5.6.0\5.6\msvc2015_64\include

VC++库目录配置为: C:\Qt\Qt5.6.0\5.6\msvc2015_64\lib

二、配置boost库只需六步

1、下载

进入boost下载中心,http://www.boost.org/users/history/

推荐下载boost1.59.0,然后下载boost_1_59_0.zip。

2、解压zip,复制解压出来的boost_1_59_0文件夹到你想要的boost安装位置

注意这个复制就决定了你想把boost安装到哪里了

3、用命令行cmd进入boost_1_59_0文件夹下,输入bootstrap.bat

4、几秒钟后,文件夹下出现bjam.exe,继续在当前cmd窗口输入bjam.exe

5、全自动识别vs和vc版本,10-20分钟后,命令行停止输出,boost_1_59_0下出现stage文件夹,安装完成。

6、新建测试程序,

配置vc++ include目录为: D:\Program Files\boost_1_59_0

配置vc++ libs目录为: D:\Program Files\boost_1_59_0\stage\lib

提供测试代码如下

#include <boost/lexical_cast.hpp>
#include <iostream>
using namespace std;
int main()
{
using boost::lexical_cast;
int a = lexical_cast<int>("123");
double b = lexical_cast<double>("123.0123456789");
string s0 = lexical_cast<string>(a);
string s1 = lexical_cast<string>(b);
cout << "number: " << a << "  " << b << endl;
cout << "string: " << s0 << "  " << s1 << endl;
int c = 0;
try {
c = lexical_cast<int>("abcd");
}
catch (boost::bad_lexical_cast& e) {
cout << e.what() << endl;
}
getchar();
return 0;
}

以上这是我成功配置Boost的方式,未考虑vs版本和x86 or x64问题

如果下次出现问题,版本匹配等担忧,请到这里链接下载最佳匹配vs版本和windows位数的exe
https://sourceforge.net/projects/boost/files/boost-binaries/1.59.0/
三、下载安装cmake

Cmake for windows 就是在windows下用cmake指令编译cmakelist中的文件

1. 下载cmake,根据操作系统选择相应的zip版本,然后解压到目标文件夹
https://cmake.org/download/
2. 修改环境变量,添加 D:\Program Files\cmake-3.8.0-win64-x64\bin 到Path环境变量

四、 安装配置CGAL只需四步

1. 下载CGAL

我选择CGAL-4.9
http://www.cgal.org/download/windows.html
把下载下来的exe文件打开安装,默认安装到C:\dev

选择CGAL位数时,我选择64位,因为侧重于开发Debug x64的程序

2. CMAKE编译出sln

打开刚才CMAKE文件夹下的CMake-GUI.exe

where is the source code路径为C:\dev\CGAL-4.9

where to build the binary路径为C:\dev\CGAL-4.9\build

单击Configure,选择“Visual Studio 14 2015 x64”,对应于64位版本和Visual Studio 2015,没有x64的对应32位版本的vs。多次configure直到没有红色错误出现,这一步常有各种问题,多试几次,或者google一下,成功会看到Configure Done。

最后单击Generete生成工程文件。会看到Generate Done。

3. vs编译SLN

在C:\dev\CGAL-4.6\build下使用Visual Studio2015打开工程文件 CGAL.sln,对ALL_BUILD这个项目点击右键进行编译。

把编译生成的bin目录添加到系统环境变量path中:C:\dev\CGAL-4.9\build\bin

后补注意:以后如果想在release平台下运行cgal,此处编译时也要用相应的release平台编译器,debug同理。

4.vs项目属性配置

include目录:

C:\dev\CGAL-4.9\build\include;

C:\dev\CGAL-4.9\auxiliary\gmp\include;

C:\dev\CGAL-4.9\include;

libs库目录

C:\dev\CGAL-4.9\build\lib;

C:\dev\CGAL-4.9\auxiliary\gmp\lib;

附加测试代码

//新建一个控制台应用程序,并添加如下代码
#include <iostream>
#include <boost/format.hpp>
#include <QtGui>
#include <CGAL/Qt/GraphicsViewNavigation.h>
#include <QLineF>
#include <QRectF>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QGraphicsScene scene;
scene.setSceneRect(0,0, 100, 100);
scene.addRect(QRectF(0,0, 100, 100), QPen(QColor(255,0,0)));
scene.addLine(QLineF(0,0, 100, 100));
scene.addLine(QLineF(0,100, 100, 0));
QGraphicsView* view = new QGraphicsView(&scene);
CGAL::Qt::GraphicsViewNavigation navigation;
view->installEventFilter(&navigation);
view->viewport()->installEventFilter(&navigation);
view->setRenderHint(QPainter::Antialiasing);
view->show();
return app.exec();
}


遇到了小问题,运行时有:("the program can't start
because cgal-vc100-mt-gd-4.2.dl is missing")

解决方案:

 In case that the compilation succeeds but the linke
9a6b
r is unable to find cgal-related dlls ("the program can't start because cgal-vc100-mt-gd-4.2.dl is missing") find these files in the CGAL directory and copy them either
to the system32 (我copy到了C:\Windows\SysWOW64下面因为我是64bit)folder of windows, or the folder of the visual studio project.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: