`
huozheleisi
  • 浏览: 1226961 次
文章分类
社区版块
存档分类
最新评论

visual studio 2008下装CGAL

 
阅读更多

visual studio 2008下装CGAL

1、安装CGAL需要boost,qt的库,我是在win7下装的

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

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

3)、获得最新版本的QT(目前是4.5.3),从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 增加到环境变量当中。

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

3安装boost

这个教程上讲的boost的安装会出现问题 http://acg.cs.tau.ac.il/cgal-at-tau/installing-cgal-and-related-programs-on-windows

就是boost thread no found。原因在这个网站上有分析 https://lists-sop.inria.fr/sympa/arc/cgal-discuss/2009-11/msg00131.html

If you compiled Boost using Visual Studio, I doubt you can use it with the MinGW g++ compiler. In C++ world, binaries coming from different compilers (even even different compiler versions of the same compiler suite) are not binary compatible.You need to choose if you want to use CGAL with MinGW or Visual. Then you need to compile Boost and Qt with the same compiler.

VS2008中编译Boost 1.38出处(http://blog.csdn.net/wrx_2009/archive/2009/06/04/4242841.aspx

编译Boost 1.38
一、下载Boost
首先,我们到http://www.boost.org去下载 boost1.38的代码包。得到一个压缩包boost_1_38_0.zip,你也可以选择下载其它格式的。

然后我们把它解压出来,我把它解压在D盘根目录下面:

二、获取编译工具
首先,我们需要到bjam.exe这是一个用于编译的工具。

接下来我将会在Visual Studio 2008 SP1简体中文专业版中编译Boost1.38。我们去开始菜单,使用管理员身份运行Visual Studio 2008 命令提示(非Vista请无视):

然后我们通过cd等DOS指令进入到:

Setting environment for using Microsoft Visual Studio 2008 x86 tools.

C:/Windows/system32>d:

D:/>cd boost_1_38_0

D:/boost_1_38_0>cd tools

D:/boost_1_38_0/tools>cd jam

D:/boost_1_38_0/tools/jam>cd src

D:/boost_1_38_0/tools/jam/src>

然后我们在这个src目录下面执行build.bat:

D:/boost_1_38_0/tools/jam/src>build.bat

然后我们稍等一小会儿等待系统自动为我们生成编译工具。

生成完毕之后src目录下会出现一个bin.ntx86目录。进入这个目录会看见bjam.exe。

我们把这个bjam.exe拷贝到boost 1.38的根目录即我的D:/boost_1_38_0。

同上面的方法打开Visual Studio 2008 命令提示,进入D:/boost_1_38_0。通过如下命令我们就可以查看当前版本的Boost的哪些组件需要编译了,因为Boost大部分组件都是以模板的形式存在的,不需要编译:

D:/boost_1_38_0>bjam --show-libraries

The following libraries require building:

- date_time

- filesystem

- function_types

- graph

- iostreams

- math

- mpi

- program_options

- python

- regex

- serialization

- signals

- system

- test

- thread

- wave

三、编译Boost1.38

我们再去D盘根目录创建一个我们的目标安装文件夹:D:/BoostLib 1_38

接下来使用默认的方式将Boost1.38完整编译到目标文件夹:

D:/boost_1_38_0>bjam install --prefix="D:/BoostLib 1_38" debug

剩下的参数都用默认的了。敲下回车,好了,开始耐心等待编译完成吧。在此之前请确认您的D盘的剩余空间,要完整编译需要大约3G的剩余空间,主要是会生成很多临时文件,编译连接完之后我们可以删除掉的。曾经在网上看到说需要12G的空间,编译需要好几个小时,可能是现在不一样了吧,呵呵,电脑配置越来越好了。而且整个编译过程也需要一定的时间,编译Debug版本大约需要40-80分钟不等,Release也差不多,根据不同的机器配置会有所不同,当然配置越好越快啦。

编译的过程中会出现很多的Warning,你可以无视它们,基本上用于学习的目的,你很难很因为这些Warning而使得程序挂掉。

warning: No toolsets are configured.

warning: Configuring default toolset "msvc". // 这里由于我们没有选择编译器,所以这里默认选择了VC,由于我们是在Visual Studio 2008的命令提示下面,因此自动选择了VC9。VC2005也是同样的道理,我们选择VC2005的命令提示符就可以了。

warning: If the default is wrong, your build may not work correctly.

warning: Use the "toolset=xxxxx" option to override our guess.

warning: For more configuration options, please consult

编译的过程中会自动的帮你Copy一些诸如模板头文件等到目标文件夹去:

这个Copy过程大约需要三分钟。完成之后便开始编译:

期间会有一些警告,这些都可以无视。开始编译之后会在lib文件夹中出现相应的lib和dll文件,并且由于时间的推移会越来越多,这至少说明您的编译过程正在进行中。而且在编译的过程中还会发生COPY行为。

大家可以看看Boost生成的这些Lib文件,比如boost_regex-vc90-mt-gd-1_38.lib。它的命名很考究的。

boost代表这是boost库的组件

regex代表这个是正则表达式的库

VC90代表它是什么编译器版本

mt代表它支持多线程/ Multithreads

gd代表这是debug版本

1_38代表了Boost的版本号

是不是很有艺术感呢?

另外还有一些这样的Lib文件,比如libboost_iostreams-vc90-mt-gd-1_38.lib。它以libboost开头,这表示这些lib是静态库文件,属于静态连接的库文件。它们没有对应的dll文件。同时您也可以注意到它们都比只具备索引功能的lib大得多。跟动态库版本有啥区别不用我解释了吧?

O(∩_∩)O~

Debug版本编译完我生成了107个文件,你有多少个呢?

好了,接下来我们使用类似的步骤来编译Release版本的Boost:

Release版本的Lib和Dll的命名和Debug版本的差别就在于没有gd,比如:boost_math_c99f-vc90-mt-1_38.lib。

在等待了和编译Debug差不多的时间之后,我们的Boost就成功编译了。

为了符合我们通常SDK的习惯,我们把D:/BoostLib 1_38/include/boost-1_38/下面的boost目录全部拷贝到include目录下面,然后再把boost-1_38这个空的文件夹删除。

现在我们的所有头文件都在include文件夹下面了,保留boost文件夹只是为了符合boost的习惯;所有的lib和dll都位于lib文件夹下面。

四、配置IDE和删除临时文件

但是整个过程还没有结束,我们还需要配置IDE。打开Visual Studio 2008 SP1(其它VC开发平台也类似),选择“工具”,再选择“选项”,然后在“项目和解决方案”下面选择vc++目录,在“包含目录”下面添加Boost的include路径:

在库文件下面添加Boost的lib路径:

现在Boost的安装目录已经膨胀到了1.04G:

源代码的目录,即D:/boost_1_38_0已经变得硕大无比,因为生成了大量的临时文件,我建议您删除该文件夹下面的bin.v2即可。

爽,编译完成,赶快来段代码,试试:

接下来,你就可以好好享受Boost的奇妙了。

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/wrx_2009/archive/2009/06/04/4242841.aspx

4、安装QT (出自http://blog.csdn.net/scarletty/archive/2009/05/24/4212703.aspx)

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.3

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

8)、同意license,等待一会

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

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

11)、QT安装完成

12)、重启电脑

5、安装CGAL

1)、最终的时候安装CGAL,运行安装程序,选择你的编译器及所有的Variants,下一步,下一步

2)、我建议安装在 C:/CGAL/CGAL-3.5

3)、选中所有的环境变量,等待完成,包括最后的下载

4)、增加环境变量QTDIR = C:/Qt/4.5.3

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

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

7)、键入cd C:/CGAL/CGAL-3.5

8)、运行cmake-gui .(很重要,.表示当前目录)

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

10)、如果你安装了Cygwin,configure将失败,编辑GMP_INCLUDE_DIR和MPFR_INCLUDE_DIR为C:/CGAL/CGAL-3.5/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)

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

15)、在C:/CGAL/CGAL-3.5中将会产生一个解决方法,用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.4/bin;C:/Program Files/CMake 2.8/bin;C:/CGAL/CGAL-3.5/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.3/include/QtCore","C:/Qt/4.5.3/include/QtCore","C:/Qt/4.5.3/include/QtGui","C:/Qt/4.5.3/include/QtGui","C:/Qt/4.5.3/include","C:/Qt/4.5.3/include/ActiveQt","debug",".",C:/Qt/4.5.3/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.3/lib/qtmaind.lib C:/Qt/4.5.3/lib/QtGuid4.lib C:/Qt/4.5.3/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 ------------------

----------------- 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

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics