由于项目需要,接触到coolprop,C++源码,py的文档,但可用cmake编译为java。
开个专栏,不定期更新coolprop-java 调用心得,项目结束后会把代码放出来,欢迎讨论。
排错记录:
1、win10下命令框执行报各种环境错误
cmake .. -DCOOLPROP_JAVA_MODULE=ON -DBUILD_TESTING=ON
直接装个Ubuntu(win10应用商店一键安装),sudo apt install真好用。
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt install cmake
sudo apt-get install python3
sudo update-alternatives --config python
sudo update-alternatives --set python /usr/bin/python3.6
2、报错找不到python3:
CMake Warning at CMakeLists.txt:283 (find_package):
By not providing "FindPython3.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Python3", but
CMake did not find one.
Could not find a package configuration file provided by "Python3" with any
of the following names:
Python3Config.cmake
python3-config.cmake
看起来是CMakeLists.txt中的CMAKE_MODULE_PATH中少路径。
打开这个文件,全局搜CMAKE_MODULE_PATH,找到两处这个:
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/dev/cmake/Modules/")
把python的路径加到这两个里面进去
$ which python3
/usr/bin/python3
修改后:
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/dev/cmake/Modules/" "/usr/bin/python3")
1、正如coolprop所讲的那样,需要先安装swig环境
安装swig必须要先安装pcre
#官网下一个安装包
$ tar -zxvf pcre-8.41.tar.gz
# 改权限的
$ chmod -R 777 pcre-8.41
$ cd pcre-8.41/
$ ./configure
$ make
$ sudo make install
安装swig:
$ tar -zxvf swig-4.0.2.tar.gz
# 改权限的
$ chmod -R 777 swig-4.0.2
$ cd swig-4.0.2/
$ ./configure
$ make
$ sudo make install
3、linux camke 安装
# 解压
tar -zxv -f cmake-3.19.1.tar.gz
# 进入文件夹
cd cmake-3.19.1/
# 安装
~/cmake-3.19.1$ ./bootstrap
# 当提示:
# ---------------------------------------------
# CMake has bootstrapped. Now run make. 执行
~/cmake-3.19.1$ make
#[100%] Built target foo
~/cmake-3.19.1$ sudo make install
# 安装成功
~/cmake-3.19.1$ cmake --version
cmake version 3.19.1
执行:
:/mnt/f/CoolProp/CoolProp/build$ cmake .. -DCOOLPROP_JAVA_MODULE=ON -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release
-- COOLPROP_INSTALL_PREFIX=/mnt/f/CoolProp/CoolProp/install_root
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CoolProp version: 6.4.2dev
-- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.17", minimum required is "2.7")
-- Found LibDL: /usr/lib/x86_64-linux-gnu/libdl.so
-- Looking for C++ include memory
-- Looking for C++ include memory - found
-- Performing Test HAVE_SHARED_PTR_IN_STD_NAMESPACE
-- Performing Test HAVE_SHARED_PTR_IN_STD_NAMESPACE - Success
-- Found shared_ptr in std namespace using <memory> header.
-- Found SWIG: /usr/local/bin/swig (found version "4.0.2")
-- Found Java: /opt/java/jdk1.8.0_221/bin/java (found version "1.8.0_221")
-- Found JNI: /opt/java/jdk1.8.0_221/jre/lib/amd64/libjawt.so
-- JAVA_INCLUDE_PATH = /opt/java/jdk1.8.0_221/include
CMake Deprecation Warning at /usr/local/share/cmake-3.12/Modules/UseSWIG.cmake:496 (message):
SWIG_ADD_MODULE is deprecated. Use SWIG_ADD_LIBRARY instead.
Call Stack (most recent call first):
CMakeLists.txt:1189 (SWIG_ADD_MODULE)
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/f/CoolProp/CoolProp/build
研究内容:
一、 HESO
HelmholtzEOSMixtureBackend