欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 游戏 > Windows下编译SALOME

Windows下编译SALOME

2025/7/7 21:14:57 来源:https://blog.csdn.net/qq_26221775/article/details/147140833  浏览:    关键词:Windows下编译SALOME

本文以笔记的形式记录在Windows下编译SALOME的流程。

零、环境

操作系统WIndows 10
Visual StudioVisual Studio 2022 Community
Visual Studio Code1.92.1
CMakeCMake-3.24.2

一、工具及依赖

 1.1 VS Code

下载并安装Visual Studio Code, 同时安装以下插件,

Task Explorer

Output Colorizer

Git Extension Pack

Git Graph

Remote Developement

Remote X11

Code Runner

Modern Fortran

FORTRAN InstelliSense

Fortran Breakpoint Support

C/C++ Extension Pack

C++ TestMate

Python Extension Pack
C# Dev Kit
Extension Pack for Intel Software Developer Tools
Nsight Visual Studio Code Edition

1.2 VCPKG

下载vcpkg到D:\,并完成配置

git clone https://github.com/Microsoft/vcpkg.git
cd D:\vcpkg
mkdir D:\vcpkg\binary-cache
mkdir D:\vcpkg\asset-cache
set "VCPKG_BINARY_SOURCES=clear;files,D:\vcpkg\binary-cache,readwrite"
set "X_VCPKG_ASSET_SOURCES=clear;x-azurl,file://D:/vcpkg/asset-cache,,readwrite"
bootstrap-vcpkg.bat

 注意:限于从国外网站下载速度较慢,考虑使用代理,

set "HTTP_PROXY=http://192.168.X.X:7890"
set "HTTPS_PROXY=http://192.168.X.X:7890"

通过vcpkg可以方便的安装第三方库,常用命令如下表

安装packagevcpkg install <package-name>
搜索packagevcpkg search <package-name>
已安装packagevcpkg list

然后,按照下表安装第三方依赖库

PackageDescription
pythonvcpkg install python3
pthreadvcpkg install pthread
cppunitvcpkg install cppunit
boostvcpkg install boost
qt
occ
vtk

二、下载SALOME

由于SALOME每个模块采用了单独的Git仓库进行代码托管,因此,需要手动下载SALOME相关模块。

新建fetch-salome.sh文件,并添加以下内容,

git clone https://github.com/SalomePlatform/.github.git
git clone https://github.com/SalomePlatform/adao.git
git clone https://github.com/SalomePlatform/adao_interface.git
git clone https://github.com/SalomePlatform/blsurfplugin.git
git clone https://github.com/SalomePlatform/calculator.git
git clone https://github.com/SalomePlatform/common_geometry_lib.git
git clone https://github.com/SalomePlatform/component.git
git clone https://github.com/SalomePlatform/configuration.git
git clone https://github.com/SalomePlatform/datafiles.git
git clone https://github.com/SalomePlatform/documentation.git
git clone https://github.com/SalomePlatform/eficas.git
git clone https://github.com/SalomePlatform/eficas_tools.git
git clone https://github.com/SalomePlatform/geom.git
git clone https://github.com/SalomePlatform/ghs3dplugin.git
git clone https://github.com/SalomePlatform/gmshplugin.git
git clone https://github.com/SalomePlatform/gui.git
git clone https://github.com/SalomePlatform/hello.git
git clone https://github.com/SalomePlatform/hexablock.git
git clone https://github.com/SalomePlatform/hexablockplugin.git
git clone https://github.com/SalomePlatform/hexoticplugin.git
git clone https://github.com/SalomePlatform/homard.git
git clone https://github.com/SalomePlatform/hybridplugin.git
git clone https://github.com/SalomePlatform/jobmanager.git
git clone https://github.com/SalomePlatform/kernel.git
git clone https://github.com/SalomePlatform/libbatch.git
git clone https://github.com/SalomePlatform/med.git
git clone https://github.com/SalomePlatform/MEDCoupling_tutos.git
git clone https://github.com/SalomePlatform/medreader.git
git clone https://github.com/SalomePlatform/medcoupling.git
git clone https://github.com/SalomePlatform/meshbooleanplugin.git
git clone https://github.com/SalomePlatform/mmgplugin.git
git clone https://github.com/SalomePlatform/netgenplugin.git
git clone https://github.com/SalomePlatform/openturns_salome.git
git clone https://github.com/SalomePlatform/paravis.git
git clone https://github.com/SalomePlatform/paravisaddons_common.git
git clone https://github.com/SalomePlatform/pmml.git
git clone https://github.com/SalomePlatform/py2cpp.git
git clone https://github.com/SalomePlatform/pycalculator.git
git clone https://github.com/SalomePlatform/pyhello.git
git clone https://github.com/SalomePlatform/SALOME.git
git clone https://github.com/SalomePlatform/salome_bootstrap.git
git clone https://github.com/SalomePlatform/sat.git
git clone https://github.com/SalomePlatform/sat_salome.git
git clone https://github.com/SalomePlatform/shaper.git
git clone https://github.com/SalomePlatform/shaper_study.git
git clone https://github.com/SalomePlatform/smesh.git
git clone https://github.com/SalomePlatform/solverlab.git
git clone https://github.com/SalomePlatform/top_ii_vol.git
git clone https://github.com/SalomePlatform/yacs.git
git clone https://github.com/SalomePlatform/yacsgen.git
git clone https://github.com/SalomePlatform/ydefx.git

在fetch-salome.sh所在目录,右键启动Git Bash,然后运行上述脚本,下载相关模块代码,

sh ./fetch-salome.sh

注1:国内访问GitHub需要通过'https_proxy'环境变量设置网络代理。

export https_proxy=http://X.X.X.X:7890

三、编译salome_bootstrap

3.1 CMake配置

VariableValue
ABS_APPLI_PATHD:/YouQuan/CaeFrameworks/SALOME/VS2022SALOMEBOOTSTRAP

SALOME_BUILD_TESTS

OFF
WRAP_PYTHONOFF
PYTHON_EXECUTABLED:/vcpkg/installed/x64-windows/tools/python3/python.exe

CPPUNIT_LIBRARIES

D:/vcpkg/installed/x64-windows/debug/lib/cppunitd.lib

四、编译kernel

4.1 CMake配置

VariableValue
CMAKE_INSTALL_PREFIXD:/YouQuan/CaeFrameworks/SALOME/VS2022KERNEL
SALOME_LIGHT_ONLYON
SALOME_BUILD_TESTSOFF
SALOME_BUILD_DOCOFF
PTHREAD_LIBRARIES
OMNIORB_ROOT_DIR
OMNIORB_LIBRARY_COS4
OMNIORB_LIBRARY_COSDynamic4
OMNIORB_LIBRARY_omniDynamic4
OMNIORB_LIBRARY_omniORB4
OMNIORB_LIBRARY_omnithread
CPPUNIT_LIBRARIES

五、编译gui

5.1 CMake配置

VariableValue
CMAKE_INSTALL_PREFIXD:/YouQuan/CaeFrameworks/SALOME/VS2022/GUI

FAQs

Q1: CMake 构建 kernek模块,报如下错误

cmake] CMake Error at configuration/cmake/FindSalomePythonLibs.cmake:71 (MESSAGE):
[cmake]   Python libs and interpreter versions are NOT matching: vs 3.12.9
[cmake] Call Stack (most recent call first):
[cmake]   D:/vcpkg/scripts/buildsystems/vcpkg.cmake:893 (_find_package)
[cmake]   kernel/CMakeLists.txt:84 (FIND_PACKAGE)

 A1: Python解释器与Python开发库的版本不一致,

附录Ⅰ:VS2022.bat

新建"D:\YouQuan\CaeFrameworks\SALOME\SOURCES\VS2022.bat"文件,添加以下内容,

@echo off:: SALOME SOURCES Root
set SALOME_SRCS_ROOT=%cd%
:: VCPKG Root
set VCPKG_ROOT=D:/vcpkg
:: Path to toolchain file supplied to CMake
set CMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmakeset INCLUDE=%VCPKG_ROOT%/installed/x64-windows/include;%INCLUDE%
set LIB=%VCPKG_ROOT%/installed/x64-windows/debug/lib;%LIB%
:: Add the path of your MinGW-w64 bin folder to the Windows PATH environment variable
set PATH=%VCPKG_ROOT%/installed/x64-windows/debug/bin;%PATH%:: Packages
set PYTHON_ROOT_DIR=%VCPKG_ROOT%/installed/x64-windows
::set PYTHONINTERP_ROOT_DIR=%VCPKG_ROOT%/installed/x64-windows
set PTHREAD_ROOT_DIR=%VCPKG_ROOT%/installed/x64-windows
set CPPUNIT_ROOT_DIR=%VCPKG_ROOT%/installed/x64-windows
set BOOST_ROOT_DIR=%VCPKG_ROOT%/installed/x64-windows:: Modules
set CONFIGURATION_ROOT_DIR=%cd%/configuration:: Open VS Code in the current working folder
::code . 
code .vscode/salome.code-workspace

 附录Ⅱ: VS Code Multi-root workspaces

新建"D:\YouQuan\CaeFrameworks\SALOME\SOURCES\.vscode\salome.code-workspace"文件,添加以下内容,

{"folders": [{"path": "../configuration"},{"path": "../.github"},{"path": "../adao"},{"path": "../adao_interface"},{"path": "../blsurfplugin"},{"path": "../calculator"},{"path": "../common_geometry_lib"},{"path": "../component"},{"path": "../datafiles"},{"path": "../documentation"},{"path": "../eficas"},{"path": "../eficas_tools"},{"path": "../geom"},{"path": "../ghs3dplugin"},{"path": "../gmshplugin"},{"path": "../gui"},{"path": "../hello"},{"path": "../hexablock"},{"path": "../hexablockplugin"},{"path": "../hexoticplugin"},{"path": "../homard"},{"path": "../hybridplugin"},{"path": "../jobmanager"},{"path": "../kernel"},{"path": "../libbatch"},{"path": "../med"},{"path": "../medcoupling"},{"path": "../MEDCoupling_tutos"},{"path": "../medreader"},{"path": "../meshbooleanplugin"},{"path": "../mmgplugin"},{"path": "../netgenplugin"},{"path": "../openturns_salome"},{"path": "../paravis"},{"path": "../paravisaddons_common"},{"path": "../pmml"},{"path": "../py2cpp"},{"path": "../pycalculator"},{"path": "../pyhello"},{"path": "../SALOME"},{"path": "../salome_bootstrap"},{"path": "../sat"},{"path": "../sat_salome"},{"path": "../shaper"},{"path": "../shaper_study"},{"path": "../smesh"},{"path": "../solverlab"},{"path": "../top_ii_vol"},{"path": "../yacs"},{"path": "../yacsgen"},{"path": "../ydefx"},{"path": "."}],"settings": {}
}

附录Ⅲ: cmake-tools-kits.json

新建C:\Users\nene_\AppData\Local\CMakeTools\cmake-tools-kits.json,添加以下内容,

[{"name": "Visual Studio Community 2019 Release - amd64","visualStudio": "265d6b60","visualStudioArchitecture": "x64","isTrusted": true,"preferredGenerator": {"name": "Visual Studio 16 2019","platform": "x64","toolset": "host=x64"}},{"name": "Visual Studio Community 2019 Release - amd64_x86","visualStudio": "265d6b60","visualStudioArchitecture": "x64","isTrusted": true,"preferredGenerator": {"name": "Visual Studio 16 2019","platform": "win32","toolset": "host=x64"}},{"name": "Visual Studio Community 2019 Release - x86","visualStudio": "265d6b60","visualStudioArchitecture": "x86","isTrusted": true,"preferredGenerator": {"name": "Visual Studio 16 2019","platform": "win32","toolset": "host=x86"}},{"name": "Visual Studio Community 2019 Release - x86_amd64","visualStudio": "265d6b60","visualStudioArchitecture": "x86","isTrusted": true,"preferredGenerator": {"name": "Visual Studio 16 2019","platform": "x64","toolset": "host=x86"}},{"name": "Visual Studio Community 2022 Release - amd64","visualStudio": "63913800","visualStudioArchitecture": "x64","isTrusted": true,"preferredGenerator": {"name": "Visual Studio 17 2022","platform": "x64","toolset": "host=x64"}},{"name": "Visual Studio Community 2022 Release - amd64_x86","visualStudio": "63913800","visualStudioArchitecture": "x64","isTrusted": true,"preferredGenerator": {"name": "Visual Studio 17 2022","platform": "win32","toolset": "host=x64"}},{"name": "Visual Studio Community 2022 Release - x86","visualStudio": "63913800","visualStudioArchitecture": "x86","isTrusted": true,"preferredGenerator": {"name": "Visual Studio 17 2022","platform": "win32","toolset": "host=x86"}},{"name": "Visual Studio Community 2022 Release - x86_amd64","visualStudio": "63913800","visualStudioArchitecture": "x86","isTrusted": true,"preferredGenerator": {"name": "Visual Studio 17 2022","platform": "x64","toolset": "host=x86"}},{"name": "MinGW-w64","compilers": {"C": "D:\\msys64\\mingw64\\bin\\gcc.exe","CXX": "D:\\msys64\\mingw64\\bin\\g++.exe"},"isTrusted": true,"environmentVariables": {"CMT_MINGW_PATH": "C:\\msys64\\mingw64\\bin","MSYSTEM": "MINGW64","MSYSTEM_PREFIX": "/mingw64","PATH": "D:\\msys64\\mingw64\\bin;D:\\msys64\\usr\\bin;${env:PATH}"},"preferredGenerator": {"name": "MinGW Makefiles"}}
]

附录Ⅳ: cmake-kits.json

新建"D:\YouQuan\CaeFrameworks\SALOME\SOURCES\.vscode\cmake-kits.json"文件,添加以下内容,

[{"name": "MinGW-64","compilers": {"C": "D:\\msys64\\mingw64\\bin\\gcc.exe","CXX": "D:\\msys64\\mingw64\\bin\\g++.exe"},"isTrusted": true,"environmentVariables": {"CMT_MINGW_PATH": "C:\\msys64\\mingw64\\bin","MSYSTEM": "MINGW64","MSYSTEM_PREFIX": "/mingw64","PATH": "D:\\msys64\\mingw64\\bin;D:\\msys64\\usr\\bin;${env:PATH}"},"preferredGenerator": {"name": "MinGW Makefiles"}},{"name": "GCC 11.4.0 x86_64-linux-gnu","compilers": {"C": "/usr/bin/gcc","CXX": "/usr/bin/g++"},"isTrusted": true},{"name": "Intel(R) oneAPI DPC++/C++ Compiler 2024.2.1","compilers": {"C": "/opt/intel/oneapi/compiler/2024.2/bin/icx","CXX": "/opt/intel/oneapi/compiler/2024.2/bin/icpx"},"isTrusted": true}

 附录V: c_cpp_properties.json

新建"D:\YouQuan\CaeFrameworks\SALOME\SOURCES\.vscode\c_cpp_properties.json"文件,添加以下内容,

{"configurations": [{"name": "MSVC","includePath": ["${workspaceFolder}/**"],"defines": ["_DEBUG","UNICODE","_UNICODE"],"windowsSdkVersion": "10.0.19041.0","compilerPath": "cl.exe","cStandard": "c17","cppStandard": "c++17","intelliSenseMode": "windows-msvc-x64","configurationProvider": "ms-vscode.cmake-tools"},{"name": "MinGW-w64","includePath": ["${workspaceFolder}/**","D:/msys64/mingw64/include"],"defines": [],"compilerPath": "D:/msys64/mingw64/bin/g++.exe","cStandard": "c17","cppStandard": "c++17","intelliSenseMode": "windows-gcc-x64","configurationProvider": "ms-vscode.cmake-tools","compilerPathInCppPropertiesJson": "D:/msys64/mingw64/bin/g++.exe","configurationProviderInCppPropertiesJson": "ms-vscode.cmake-tools","mergeConfigurations": false,"browse": {"path": ["D:/msys64/mingw64/include","${workspaceFolder}"],"limitSymbolsToIncludedHeaders": true}},{"name": "Mac","includePath": ["${workspaceFolder}/**"],"defines": [],"macFrameworkPath": ["/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"],"compilerPath": "/usr/bin/clang","cStandard": "c17","cppStandard": "c++17","intelliSenseMode": "macos-clang-arm64"},{"name": "Linux-GCC","includePath": ["${workspaceFolder}/**"],"defines": [],"compilerPath": "/usr/bin/g++","cStandard": "c17","cppStandard": "c++17","intelliSenseMode": "gcc-x64","browse": {"path": ["${workspaceFolder}"],"limitSymbolsToIncludedHeaders": true,"databaseFilename": ""}}],"version": 4
}

附录:CMakeLists.txt

新建"D:\YouQuan\CaeFrameworks\SALOME\SOURCES\CMakeLists.txt"文件,添加以下内容,

project(SALOME)#subdirectories
add_subdirectory(salome_bootstrap)
add_subdirectory(kernel)
add_subdirectory(gui)

附录:CMakeUserPresets.json

新建"D:\YouQuan\CaeFrameworks\SALOME\SOURCES\CMakeUserPresets.json"文件,添加以下内容,

{"version": 4,"cmakeMinimumRequired": {"major": 3,"minor": 20,"patch": 0},"configurePresets": [{"name": "default","hidden": true,"displayName": "Default Config","description": "Default build configuration","binaryDir": "${sourceDir}/build/${presetName}","cacheVariables": {"CMAKE_INSTALL_PREFIX": "${sourceDir}/../${presetName}","CMAKE_BUILD_TYPE": "Debug"          }},        {"name": "vs2022","hidden": false,"inherits": "default","displayName": "Visual Studio 17 2022","description": "This build is using Visual Studio 17 2022 generator","generator": "Visual Studio 17 2022","toolset": "host=x64","architecture": "x64","cacheVariables": {"CMAKE_TOOLCHAIN_FILE": "D:/vcpkg/scripts/buildsystems/vcpkg.cmake","WRAP_PYTHON":"OFF","SALOME_BUILD_TESTS":"OFF","PYTHON_ROOT_DIR": "D:/vcpkg/installed/x64-windows","PYTHONINTERP_ROOT_DIR":"D:/vcpkg/installed/x64-windows","PYTHON_EXECUTABLE":"D:/vcpkg/installed/x64-windows/tools/python3/python.exe","PTHREAD_ROOT_DIR":"D:/vcpkg/installed/x64-windows","PYTHONLIBS_ROOT_DIR":"D:/vcpkg/installed/x64-windows","CPPUNIT_INCLUDE_DIRS":"D:/vcpkg/installed/x64-windows/include/cppuint","CPPUNIT_LIBRARIES":"D:/vcpkg/installed/x64-windows/debug/lib/cppunitd.lib"},"environment": {"CONFIGURATION_ROOT_DIR": "${sourceDir}/configuration"},"condition": {"type": "equals","lhs": "${hostSystemName}","rhs": "Windows"}}],"buildPresets": [{"name": "vs2022","displayName": "VS2022","configurePreset": "vs2022"}],"testPresets": [{"name": "vs2022","displayName": "VS2022","configurePreset": "vs2022"}]
}

 参考资料

SALOME

VS Code Multi-root workspaces

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词