Windows上编译计算Palabos案例指南

时间:2024-04-07 18:05:16

Windows上编译计算Palabos

Palabos用户文档

原始文档

The C++ Integrated Development Environment (IDE) Code::Blocks is free, and you can download binaries for various flavors of Windows and Linux, and for Mac OS X (see codeblocks). A configuration file is delivered with the Palabos releases which can be used to compile Palabos with Code::Blocks. This approach was successfully tested under Windows and Linux, and neither Python nor make are needed for the compilation process.
Open the project file $(PALABOS)/codeblocks/Palabos.cbp under code::blocks, build and run the project. By default, the example program examples/showCases/cavity2d.cpp is compiled. To compile another example or your own program, remove the file cavity2d.cpp from the list of source files, and replace it by another one. The GIF images and other output files from the program are written in the directory $(PALABOS)/codeblocks/tmp/.
Code::Blocks is a cross-compiler environment, and you can in principle use it with just any C++ compiler. In particular, you can use it with the free GCC compiler. This compiler does not even need to be installed separately under Windows if you download the version of Code::Blocks which is directly packaged with the GCC port MinGW.
Note that the Palabos code does not compile with Visual C++, and we don’t know why; any suggestion is appreciated. In the meantime, you should use another compiler, such as GCC, the Intel compiler, or the Portland Group compiler.
As mentioned above, the Palabos download provides a project file for the free IDE Code::Blocks, through which you can easily use any of these compilers (we have only tested GCC/MinGW, though). If you have no C++ compiler installed on your system (other than Visual C++), remember to download the version of Code::Blocks which is packaged with the GCC port MinGW, after which you can directly compile Palabos.
Just as under Linux, you need to install ImageMagick if you want Palabos to be able to produce GIF images. If this fails, Palabos will write images in the PPM format, which is not recognized by most of the standard image viewers under Windows. In this case, you have the possibility to install the free image editor Gimp, which can view PPM images and convert them to another format.
It should also be reminded that the pathnames in the Palabos examples are written using the Unix convention, with slashes between directory names, while Windows uses backslashes. Under Windows, it is therefore recommended to change lines like
global::directories().setOutputDir("./tmp/");
to something like
global::directories().setOutputDir(".\\tmp\\");
although the programs appear to behave reasonably well even when you don’t do this.

文档翻译

c++集成开发环境(IDE)code::blocks是免费的,您可以下载Windows和Linux以及Mac OS X等格式的二进制文件(参见code::blocks)。配置文件随Palabos版本一起发布,可以使用code::blocks来编译Palabos。此方法已在Windows和Linux下成功测试,编译过程不需要Python或make。
在code::blocks中打开项目文件$(PALABOS)/codeblocks/palabos.cbp,建设和运行项目。默认情况下,编译示例程序examples/showCases/cavity2d.cpp。要编译另一个示例或您自己的程序,请从源文件列表中删除cavity2d.cpp文件,并将其替换为另一个文件。来自程序的GIF图像和其他输出文件写在$(PALABOS)/codeblocks/tmp/目录中。
code::blocks是一个交叉编译器环境,原则上可以与任何c++编译器一起使用。特别是,您可以在免费的GCC编译器中使用它。如果您下载直接与GCC端口MinGW打包的code::blocks的版本,那么这个编译器甚至不需要单独安装在Windows下。
注意,Palabos代码不能用Visual c++编译,我们不知道为什么;欢迎提出任何建议。同时,您应该使用其他编译器,如GCC、Intel编译器或Portland Group编译器。
如上所述,Palabos下载中,为code::blocks提供了一个项目文件,通过这个文件,您可以轻松地使用任何这些编译器(尽管我们只测试了GCC/MinGW)。如果您的系统上没有安装c++编译器(除了Visual c++),请记住下载与GCC端口MinGW打包的code::blocks的版本,然后您可以直接编译Palabos。
与在Linux下一样,如果希望Palabos能够生成GIF图像,则需要安装ImageMagick。如果失败,Palabos将以PPM格式编写图像,而大多数Windows下的标准图像查看器无法识别这种格式。在这种情况下,您可以安装免费的图像编辑器Gimp,它可以查看PPM图像并将其转换为另一种格式。
还应该注意,Palabos示例中的路径名是使用Unix约定编写的,目录名之间有斜杠,而Windows使用反斜杠。因此,在Windows下,建议更改类似的行
全球:目录().setOutputDir ("/tmp/.");
到类似的
全球:目录().setOutputDir (”.\ \ \ tmp \ \ \ \ ");
即使你不这样做,程序也表现得相当好。

解释说明

code::blocks下载地址
请选择带mingw编译期的版本下载,我下载的codeblocks-17.12mingw-setup.exe
装好,打开$(PALABOS)/codeblocks/palabos.cbp文件,所有配置就都配置好了。
一开始的文件是cavity2D.cpp,直接调试,如果显示
ERROR: You need to specify a debugger program in the debuggers’s settings.
请参考
解决方法:https://blog.csdn.net/baibaigao/article/details/80990266
生成正式版本时,也就是release时,同时只能有一个工程在showcases目录下,多项目文件放在这里,无法生成可执行文件,会报错。
调试时,也就是debug时,不用关心这个,选到你要调试的文件,直接调试就行。
Windows上编译计算Palabos案例指南新项目添加,旧项目删除,即可调试其他案例
Windows上编译计算Palabos案例指南