用Visual Studio 2008成功编译GMSH 2.5

来源:互联网 发布:淘宝客助手手机版 编辑:程序博客网 时间:2024/05/22 02:15

因为项目,需要在WINDOWS下面编译GMSH(一种开源的有限元网格剖分工具(MESH) http://geuz.org/gmsh/)。

帮助说明如下:

Build Gmsh using CMake's graphical user interface* Launch CMake and fill-in the two top input fields (telling where the  Gmsh source directory is located and where you want the Gmsh binary  to be created).* Click on "Add entry" and define the variable CMAKE_PREFIX_PATH, of  type "PATH", pointing to the location(s) of any external package(s)  (FLTK, BLAS/LAPACK, etc.) installed in non-standard directories.   (If you are using our pre-compiled "gmsh dependencies" package  (http://geuz.org/gmsh/bin/Windows/gmsh-dep-msvc2008-release.zip)  with Visual Studio on Windows simply point CMAKE_PREFIX_PATH to the  "gmsh-dep" directory.)* Click on "Configure" and choose your compiler (e.g. Visual Studio).* Optionally change some configuration options (re-run "Configure"  every time you change some options).* Once you are happy with all the configuration options, click on  "Generate".* Go to the build directory and build Gmsh using your chosen compiler.  (With Visual Studio double-click on "gmsh.sln". If you are using our  pre-compiled "gmsh dependencies" package you must use the "Release"  or "RelWithDebInfo" build type.)
看完后,丈二和尚摸不到头脑。

不管怎么样,这个软件用到了QT4,所以先把WINDOWS下面的QT环境装好了。这里,我使用的是visual studio 2008+ Qt4.7 sdk for windows(Qt_SDK_Win_offline_v1_1_4_en.exe)+vs插件(qt-vs-addin-1.1.9.exe)的QT环境。

然后,去GMSH的FTP上下载gmsh-dep-msvc2008-release.zip 这个包里面含有GMSH所用到的一些第三方库,如FLTK,GSL。这些库如果自己安装好了,就不用下这个,但是在windows下面安装不是太方便,所以GMSH提供了windows下编译好的库。将包里面“gmsh-dep"目录提取出来。

其次安装CMAKE。直接去CMAKE的官网上下载绿色版的CMAKE 2.86(http://www.cmake.org/files/v2.8/cmake-2.8.6-win32-x86.zip)

到了这里,所有需要的”材料“就都准备好了,当然,GMSH的源代码是早就准备好的!

下面,运行CMAKE,安装上面的说明一步步来,就OK了!

我再解释一下好了:

* Launch CMake and fill-in the two top input fields (telling where the  Gmsh source directory is located and where you want the Gmsh binary  to be created).
运行CMake,填上GMSH的源代码路径、生成路径。

* Click on "Add entry" and define the variable CMAKE_PREFIX_PATH, of  type "PATH", pointing to the location(s) of any external package(s)  (FLTK, BLAS/LAPACK, etc.) installed in non-standard directories. 
点”Add entry"添加“PATH”类型的变量CMAKE_PREFIX_PATH, 指向上面说到的gmsh-dep目录

* Click on "Configure" and choose your compiler (e.g. Visual Studio).
点Configure,选择编译器。我的是visual studio 9 2008.

* Optionally change some configuration options (re-run "Configure"  every time you change some options).
会成才许多变量,如果有不合适的可以修改。我没有修改。

* Once you are happy with all the configuration options, click on  "Generate".
点GENERATE。另外,这步不能打开VS2008,不如会报错。

* Go to the build directory and build Gmsh using your chosen compiler.
最后,点生成目录下的.sln文件,转到VS2008中生成可执行文件。注意,只能生成release类型的哦!好像是因为我没有安装那些第三方的软件,直接用的人家给的库的原因。

等一会就生成完了。可是我的可执行文件比gmsh官方给出的大了1M(一共才6M多),不知道为什么。


大功告成,回去睡觉咯~