花褪残红青杏小。燕子飞时,绿水人家绕。

Coolprop的编译方法

菜鸟编程 十五楼的鸟儿 14202浏览 0评论

主要方法来自于这里:

http://www.coolprop.org/coolprop/wrappers/Csharp/index.html#user-compiled-binaries

补充了一些踩坑过程。

〇、依赖

来源:http://www.coolprop.org/coolprop/wrappers/index.html#wrapper-common-prereqs

编译过程需要依赖这些东西:

git (to interface with the CoolProp repository at https://github.com/CoolProp/CoolProp)

python (to generate the header files and convert them to binary file)

CMake (platform-independent software to generate makefiles)

C++ compiler

7-zip

 

都需要加入到环境变量中,即:在命令行直接执行时,可以调用的到。比如:

On Windows, download the newest binary installer for CMake from CMake downloads. Run the installer. Check that at the command prompt you can do something like:

C:\Users\XXXX>cmake -version
cmake version 2.8.12.2


For git, your best best is the installer from http://msysgit.github.io/. Check that at the command prompt you can do something like:

C:\Users\XXXX>git --version
git version 1.9.4.msysgit.0


For 7-zip, download the installer from http://www.7-zip.org/ . Check that at the command prompt you can do something like:

C:\Users\XXXX>7z

7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18

Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...]
[<@listfiles...>]

一、下载

命令 git clone https://github.com/CoolProp/CoolProp --recursive   

这个命令因为科学网的原因,可能会下载不完整,推荐使用github desktop进行下载。

二、修改错误

修改:
coolprop\dev\generate_headers.py

gitrev_to_file 函数改为以下内容。

def gitrev_to_file(root_dir):
"""
If a git repo, use git to update the gitrevision. If not a git repo, read
the gitrevision from the gitrevision.txt file. Otherwise, fail.
"""
hashes['gitrevision'] = "myprop20230425"

修改:
coolprop\src\CoolProp.cpp

65行找不到引用,注释掉 gitrevision.h的引用

963行提示未定义标识符gitrevision,改为version

三、编译

32位
mkdir build86 && cd build86

cmake .. -DCOOLPROP_CSHARP_MODULE=ON -DCOOLPROP_NO_EXAMPLES=ON -DCOOLPROP_SWIG_OPTIONS="-namespace MyProp" -G "Visual Studio 15 2017"

cmake --build .
64位
mkdir build64 && cd build64

cmake .. -DCOOLPROP_CSHARP_MODULE=ON -DCOOLPROP_NO_EXAMPLES=ON -DCOOLPROP_SWIG_OPTIONS="-namespace MyProp" -G "Visual Studio 15 2017 Win64"

cmake --build .

编译完成后,会在build文件夹里生成 platform-independent.7z,这个压缩包里的内容是C#调用Coolprop需要的中间件。

注意上述的指令中,使用了namespace,设置为MyProp,对应生成的中间件也会跟着变化,需要配套使用。

您需要有鸟儿博客 认证开发者 账号,并且 登录 后即可查看或下载隐藏部分的内容.

了解 认证开发者 详情,或加QQ:8769298了解详情。

 

以上。

转载请注明:鸟儿博客 » Coolprop的编译方法

游客
发表我的评论 换个身份
取消评论

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址