在vs2008下安装CGAL(转载)

转载于:http://blog.csdn.net/scarletty/archive/2009/05/24/4212703.aspx

自己在实际安装中的一些不同点做了修改,意在给自己做笔记,如原作者有异议,请通知我,我将再做修改。 

在Visual Studio2008中安装CGAl

(注意:整个安装过程需要网络连接,最后指示如何在windows中增加环境变量)

1、下载需要的安装文件

1)、首先下载CGAL(3.4)的安装程序,从http://gforge.inria.fr/frs/?group_id=52(在页面的最下面)

2)、获得最新版本的CMake(目前是2.6.3),从http://www.cmake.org/cmake/resources/software.html

3)、获得最新版本的QT(目前是4.5),从http://www.qtsoftware.com/downloads/windows-cpp

4)、获得最新版本的boost(目前是1.38)从http://www.boost.org/users/download/

    或者是从http://www.boostpro.com/download 这里下载window的安装程序

 

2、安装CMake

使用默认的编译器并且不要忘记,将X:/Program Files/CMake 2.6/bin 增加到PATH当中

 

3、安装boost

1)、如果你下载的是安装程序则直接选择下一步,装时要勾上Boost.Thread和Boost.Program_options,等安装完成后,将 C:/boost/boost_1_38_0/bin添加到PATH中去即可。否则请看步骤2(本人是基于安装程序来获得了boost库的,在尝试对源文件编译时,由sln生成lib库时老是出错,所以导致在后面在编译CGAL的时候,老是提示找不到Boos_LIABRARY).

2)、新建目录c:/boost并把boost_1_38_0.7z拷贝到它里。

3)、将boost_1_38_0.7z解压到C:/boost/boost _1_38_0目录(用鼠标右键单击文件,用7zip解压。 如果您没有7zip,则从这里http://www.7-zip.org/下载并且安装)

4)、在完全解压完之前不要删除boost_1_38_0.7z

5)、打开CMD(strart->Run->cmd)然后输入 cd c:/boost/boost_1_38_0

6)、在cmd中键入  cmake-gui(这步非常重要)

7)、点击Configure选择Visual Studio2008的编译器

8)、点击“Add Entry”,新建一个boolean变量,叫做CMAKE_IS_EXPERIMENTAL,将其值设置为真

9)、点击“configure”

10)、在红色的变量中“Build Static”没有选中的话请将其选。

11)、点击Configure直到Generate按钮变为可操作的。

12)、点击Generate

13)、关闭CMake。(这一步并不是很重要)

14)、在boost路径中找到新建的解决方案Boost.sln。然后点击Build->Clean Solution,结束后点击Build->Rebuild Solution

15)、等待较长的时间……如果它提示保存及重启Visual Studio,然后尽量让大部分结束后再重启

16)、将 C:/boost/boost_1_38_0/bin添加到PATH中去

17)、注意,不要删除7zip文件。

18)、将boost文件解压到C:/boost/boost_1_38_0中(右键,用7zip解压)选择覆盖已有文件。

19)、boost安装成功

 

4、安装QT(我安装的是Trolltech.Qt.Commercial.v4.4.3版本,很快就安装好了。要将C:/Qt/4.4.3/bin添加到PATH中)

1)、注意:安装这部分花费了我5个小时,因此,你完全可以晚上开始安装。

2)、运行QT的安装程序(这是在5个小时之外的)

3)、你或许需要minGW(不是源码),因此,下载它并且把它安装到C:/MinGW。当然,直接通过QT的安装程序安装是最简单的了。如果您遇到问题(trolltech镜像),可以单独在sourceforge.net上下载minGW安装程序(最新版5.1.4),安装它,然后继续安装QT,忽视关于版本兼容性的报警信息

4)、一旦QT安装完成,将C:/MinGW/bin添加到环境变量中

5)、如果你打开QT的lib路径,你会发现这里很多文件却都不是lib文件。现在要生成lib文件。

6)、打开Visual Studio的命令提示窗口(Start->Programs->Visual Studio->Visual Studio Tools->Visual Studio CommandPrompt)然后写cd c:/QT/4.5.0

7)、在黑色窗口中写“configure”,即运行文件夹里的configure.exe程序

8)、同意license,等待一会

9)、在cmd窗口中写“nmake”,大概等待5个小时

10)、将路径 C:/Qt/4.5.0/bin添加到环境变量中

11)、QT安装完成

12)、重启电脑

 

5、安装CGAL 

1)、由于我C盘剩余空间不大了,所以我将其安装在D盘,新建目录D:/CGAL/,将CGAL-3.4.zip解压缩到该目录下。

2)、增加环境变量QTDIR = C:/Qt/4.4.3

3)、增加环境变量BOOST_ROOT = C:/boost/boost_1_38

4)、打开命令行窗口(start->run->cmd)

7)、键入cd D:/CGAL/CGAL-3.4

8)、运行cmake-gui(可以直接到开始->cmake-gui),选择source code和build binaries路径为:D:/CGAL/CGAL-3.4

9)、选择你的编译器并点击configure

10)、如果你安装了Cygwin,configure将失败,编辑GMP_INCLUDE_DIR和MPFR_INCLUDE_DIR为C:/CGAL/CGAL-3.4/auxiliary/gmp/include

11)、编辑CMAKE_BUILD_TYPE为Debug

12)、如果你希望安装演示实例,请选择WITH_demos与WITH_examples(其实没有必要安装,可以用的时候再编译)

13)、你需要增加变量Boost_INCLUDE_DIR (=C:/boost/boost_1_38_0), 并且编辑变量Boost_THREAD_LIBRARY_DEBUG (=C:/boost/boost_1_38_0/lib/libboost_thread-vc90-mt-gd-1_38.lib) 以及变量Boost_THREAD_LIBRARY_RELEASE (= C:/boost/boost_1_38_0/lib/libboost_thread-vc90-mt-1_38.lib)--这一步我没有涉及,cmake可以自动添加。

14)、点击Configure,知道Generate能够操作之后,点击Generate

15)、在C:/CGAL/CGAL-3.4中将会产生一个解决方法,用Visual Studio打开

16)、关闭CMAKE

17)、选择 Build->Clean Solution,选择 Build->Rebuild Solution。安装完成。

18)、此时,你的PATH应该是这样的:PATH=C:/Windows/system32;C:/Windows;C:/Windows/System32/Wbem;C:/Program Files/ATITechnologies/ATI.ACE/Core-Static;c:/Program Files/Microsoft SQL Server/90/Tools/binn/;C:/cygwin/bin;C:/cygwin/usr/bin;C:/cygwin/usr/local/bin;C:/cygwin/usr/X11R6/bin;C:/gs/gs8.63/bin;C:/gs/gs8.63/lib;C:/boost/boost_1_38

_0/bin;C:/cygwin/usr/include;C:/MinGW/bin;C:/Qt/4.5.0/bin;C:/Program Files/CMake 2.6/bin;C:/CGAL/CGAL-3.4/auxiliary/gmp/lib

 

 

Creating a Visual Studio Project that uses CGAL and QT

Now that you have installed CGAL you need to configure your visual studio to work with it.

Open an empty C++ project using the Win32 Console Application wizard (select empty project and click finish) File->New->Project  ... Other Languages -> C++ -> Win32 -> Win32 Console Application

When the solution loads up go to Tools->Options ... Projects and Solutions -> VC++ Directories

Make sure that Executable Files (Combobox at the top right)  contains the $(PATH) variable (at the end there)

Select Include Files in the combobox and add :

C:/CGAL/CGAL-3.4/auxiliary/gmp/include

C:/Qt/4.5.0/include

C:/boost/boost_1_38_0

C:/CGAL/CGAL-3.4/include

They should appear at that order at the topmost part of the list (use the arrows to move items up and down)

Select Library Files from the combobox and add :

C:/CGAL/CGAL-3.4/auxiliary/gmp/lib

C:/CGAL/CGAL-3.4/lib

C:/boost/boost_1_38_0/lib

C:/Qt/4.5.0/lib

Press OK until you are back at the main window

Right click your project and select Properties

Go to Configuration Properties -> C/C++ -> General. In there you will see Additional Include Directories. Copy this line there :"C:/Qt/4.5.0/include/QtCore","C:/Qt/4.5.0/include/QtCore","C:/Qt/4.5.0/include/QtGui","C:/Qt/4.5.0/include/QtGui","C:/Qt/4.5.0/include","C:/Qt/4.5.0/include/ActiveQt","debug",".",C:/Qt/4.5.0/mkspecs/win32-msvc2005

QT has a bunch of directories in their include so you need to add each directory individualy. The ones I write there should be enough for a beginner

Go to Configuration Properties -> Linker -> Input and copy the following line to the Additional Dependancies line : C:/Qt/4.5.0/lib/qtmaind.lib C:/Qt/4.5.0/lib/QtGuid4.lib C:/Qt/4.5.0/lib/QtCored4.lib

You will generaly need some of the libs as dependant files. The ones I gave above should be enoguh for a beginner program.

Thats it, you can write your code and compile it here is an example of a main.cpp that should compile now :

----------------- CUT HERE ------------------

 

#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();

}

 

----------------- CUT HERE -------------------

 

Good Luck and feel free to ask us questions.

 

 

 

Setting up PATH variable or other Enviroment variables on windows systems

 

From the desktop, right-click My Computer and click properties.

(on Vista click Advanced system settings on the left side)

In the System Properties window, click on the Advanced tab.

In the Advanced section, click the Environment Variables button.

Finally, in the Environment Variables window, highlight the path variable in the Systems Variable section and click edit. Add or modify the path lines with the paths you wish the computer to access. Each different directory is separated with a semicolon as shown below.

 

C:/Program Files;C:/Winnt;C:/Winnt/System32

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/scarletty/archive/2009/05/24/4212703.aspx

你可能感兴趣的:(properties,qt,Path,include,variables,7zip)