eclipse油藏数值模拟器的文件读写c/c++算法库libecl在windows下的编译

eclipse油藏数值模拟器的文件读写c/c++算法库libecl在windows下的编译

该库在linux操作系统下使用,但因本人应用场景为windows环境,需要将其编译成dll,这里把填坑过程做个记录:我先是从GitHub上ecl的github地址直接下载zip文件,按着里面的readme.md和WINDOWS.md两个文档,直接对解压后的zip文件进行编译,一直不成功。最后按照两个文件的步骤,编译成功了。成果的github地址:Github库地址,Gitee地址:gitee库地址
能够编译成功的流程:
1、使用Git克隆代码库而不是直接下载zip

$ git clone https://github.com/Equinor/ecl
$ mkdir ecl/build
$ cd ecl/build
$ pip install -r ../requirements.txt

2、make和install命令里的路径写对
WINDOWS.md里给出的命令

cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=%INSTALLPATH% -DBUILD_SHARED_LIBS="ON"  -DENABLE_PYTHON="ON"    -DCMAKE_BUILD_TYPE="Release" %SOURCEPATH%
 
cmake --build %BUILDPATH% --config Release --target install

%INSTALLPATH%=我这里设置的为代码库目录下面新建了一个build文件夹
%SOURCEPATH%=代码库目录
%BUILDPATH%=代码库目录
本人环境下的命令:

cmake -G "Visual Studio 17 2022" -DCMAKE_INSTALL_PREFIX=G:/ythpt/libecl-datapro-py/ecllib/ecl/build -DBUILD_SHARED_LIBS="ON"  -DENABLE_PYTHON="ON"    -DCMAKE_BUILD_TYPE="Release" G:/ythpt/libecl-datapro-py/ecllib/ecl
cmake --build G:/ythpt/libecl-datapro-py/ecllib/ecl --config Release --target install

3、按WINDOWS.md和readme.md操作
4、WINDOWS.md的内容

WINDOWS.md的内容

Compiling and Installing libecl on Windows
在Windows环境下编译和安装libecl

Prerequisits:前置条件

  • Python 2.7 or 3.x https://www.python.org/ or https://anaconda.org/(python,我的是3.10)
  • Microsoft Visual Studio https://visualstudio.microsoft.com/downloads/(Visual Studio IDE,主要是用它的MSVC)
  • Local copy of libecl(libecl库的本地copy)

Instructions:

  1. Download or clone the libecl Github repository to your local disk.
    Git克隆代码库到本地,Git前升级下Git为最新版
  2. Python 2.7 or 3.x installation
    安装Python
    • Download a python instalation or a python environment solution such as Anaconda.
  3. Download and install Microsoft Visual Studio . At a minimum libecl requires the VS Studio packages for cmake, msbuild, c and c++ compilers (CL.exe).
    下载安装VS(我的是VS2022),最低要求安装VS的cmake, msbuild, c and c++ compilers (CL.exe),这些组件,安装时勾选C++语言开发,再看看开发工具组件里面勾选,就能满足了
  4. Open a MSVC command prompt such as x64 Native Tools Command Prompt for VS 2017 from your start menu. In the open prompt, navigate to the libecl source directory you created in step 1. Use the Python package manager pip to install libecl requirements via pip install -r requirements.txt. If Python is not accessible from the prompt it may be necessary to add the Python environment location to your system path variable PATH.
    安装libecl的依赖包,我这步是直接在代码库目录下GitBash命令界面输入的,
$ git clone https://github.com/Equinor/ecl
$ mkdir ecl/build
$ cd ecl/build
$ pip install -r ../requirements.txt
  1. Execute the build commands with the desired CMAKE parameters from README.md. The cmake generator can be NMake Makefiles , Ninja or an appropriate version of MSVC. For the availble options type cmake -G in the MSVC command prompt.

    An example build and install is provided below where %VARIABLE% are user defined directory paths:

    cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=%INSTALLPATH% -DBUILD_SHARED_LIBS="ON"  -DENABLE_PYTHON="ON"    -DCMAKE_BUILD_TYPE="Release" %SOURCEPATH%
    cmake --build %BUILDPATH% --config Release --target install

用msvc编译,还是在Git命令窗口直接输入的如下命令,其中%INSTALLPATH%是在代码库目录下新建了的一个build文件夹,最后这个%SOURCEPATH%就是源代码目录

cmake -G "Visual Studio 17 2022" -DCMAKE_INSTALL_PREFIX=G:/ythpt/libecl-datapro-py/ecllib/ecl/build -DBUILD_SHARED_LIBS="ON"  -DENABLE_PYTHON="ON"    -DCMAKE_BUILD_TYPE="Release" G:/ythpt/libecl-datapro-py/ecllib/ecl

最后cmake --build %BUILDPATH% --config Release --target install编译和安装,%BUILDPATH%这个我设置成代码库根目录时,能够成功生成

cmake --build G:/ythpt/libecl-datapro-py/ecllib/ecl --config Release --target install
  1. For libecl to be accessible in Python the %INSTALLPATH%\lib\pythonX.Y\site-package and Python subdirectories must be added to the PATH and PYTHONPATH variables. Where pythonx.y is the current Python version e.g. (python2.7, python3.6 etc.) .
  2. Open a Python interactive session and run import ecl to check that the install and paths are now set.

后续再补充dll的使用

更新:编译成果dll下载链接

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Higer2008

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值