MinGW-w64下编译安装SALOME

本文探索在Windows下编译安装SALOME核心模块的方法。SALOME是开源跨平台的CAE软件集成开发平台,其每个模块用单独Git仓库托管代码,需手动下载相关模块,还需安装第三方依赖包。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SALOME是一套开源跨平台的CAE软件集成开发平台。本文旨在探索在Windows下编译安装SALOME核心模块的方法。

注1:文章内容会不定期更新,敬请关注。

注2:限于笔者研究水平,难免有不当之处,欢迎批评指正。

零、环境

操作系统WIndows 10
MSYS2msys2-x86_64-20241208
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 MinGW-w64

 下载MSYS2, 并将其安装到"D:/msys64"目录, 打开'MSYS2 MINGW64',

设置网络代理,

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

然后,安装以下依赖包

pacman -S base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cppcheck \
mingw-w64-x86_64-boost mingw-w64-x86_64-qt5 mingw-w64-x86_64-vtk \
mingw-w64-x86_64-opencascade
PrerequisitesInstructions

NumPy

SciPy

Psutil

Sphinx

pacman -S mingw64/mingw-w64-x86_64-python-numpy 

pacman -S mingw64/mingw-w64-x86_64-python-scipy 

pacman -S mingw64/mingw-w64-x86_64-python-psutil

pacman -S mingw64/mingw-w64-x86_64-python-sphinx

Swig

pacman -S mingw64/mingw-w64-x86_64-swig 

CppUnitpacman -S mingw64/mingw-w64-x86_64-cppunit

OmniORB

omniORB下载omniORB-4.1.4-x86_win32-vs9.zip,并将其安装到D:\msys64\mingw64\omniORB

Graphviz

pacman -S mingw64/mingw-w64-x86_64-graphviz

二、下载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_PATH

D:/YouQuan/CaeFrameworks/SALOME/MinGW-w64/SALOMEBOOTSTRAP
PTHREAD_LIBRARIESD:/msys64/mingw64/lib/libwinpthread.dll.a
CPPUNIT_LIBRARIESD:/msys64/mingw64/lib/libcppunit.dll.a

四、编译kernel

4.1 CMake配置

VariableValue

CMAKE_INSTALL_PREFIX

D:/YouQuan/CaeFrameworks/SALOME/MinGW-w64/KERNEL

SALOME_LIGHT_ONLY

ON

SALOME_BUILD_TESTS

OFF

SALOME_BUILD_DOC

OFF
PTHREAD_LIBRARIESD:/msys64/mingw64/lib/libwinpthread.dll.a
OMNIORB_ROOT_DIRD:/msys64/mingw64/omniORB
OMNIORB_LIBRARY_COS4D:/msys64/mingw64/omniORB/lib/x86_win32/COS4d.lib
OMNIORB_LIBRARY_COSDynamic4D:/msys64/mingw64/omniORB/lib/x86_win32/COSDynamic4d.lib
OMNIORB_LIBRARY_omniDynamic4D:/msys64/mingw64/omniORB/lib/x86_win32/omniDynamic4d.lib
OMNIORB_LIBRARY_omniORB4D:/msys64/mingw64/omniORB/lib/x86_win32/omniORB4d.lib
OMNIORB_LIBRARY_omnithreadD:/msys64/mingw64/omniORB/lib/x86_win32/omnithreadd.lib
CPPUNIT_LIBRARIESD:/msys64/mingw64/lib/libcppunit.dll.a

五、编译gui

5.1 CMake配置

VariableValue

CMAKE_INSTALL_PREFIX

D:/YouQuan/CaeFrameworks/SALOME/MinGW-w64/GUI

附录Ⅰ:MinGW-w64.bat

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

@echo off

:: SALOME SOURCES Root
set SALOME_SRCS_ROOT=%cd%
:: MinGW-w64 Root
set MinGW64_ROOT=D:/msys64/mingw64

set CPPUNIT_ROOT_DIR=%MinGW64_ROOT%
set BOOST_ROOT_DIR=%MinGW64_ROOT%
set PTHREAD_ROOT_DIR=%MinGW64_ROOT%
set PYTHON_ROOT_DIR=%MinGW64_ROOT%

:: set SALOMEBOOTSTRAP_ROOT_DIR=%SALOME_SRCS_ROOT%/salome_bootstrap

:: Add the path of your MinGW-w64 bin folder to the Windows PATH environment variable
set PATH=%MinGW64_ROOT%/bin;%PATH%

:: Preferred executable for compiling C/CXX language files.
:: set CC=%MinGW64_ROOT%/bin/gcc.exe
:: set CXX=%MinGW64_ROOT%/bin/g++.exe

set CONFIGURATION_ROOT_DIR=%cd%/configuration

:: Open VS Code in the current working folder
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": {}
}

附录Ⅲ: c_cpp_properties.json

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

{
    "configurations": [
        {
            "name": "Win32",
            "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
}

附录Ⅳ: 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: CMakeUserPresets.json

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

{
    "version": 4,
    "cmakeMinimumRequired": {
        "major": 3,
        "minor": 20,
        "patch": 0
    },
    "configurePresets": [
        {
            "name": "mingw64",
            "hidden": false,
            "displayName": "MinGW-w64",
            "description": "This build is using MinGW generator",
            "generator": "MinGW Makefiles",
			"binaryDir": "${sourceDir}/out/build/${presetName}",
            "cacheVariables": {
				"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",                
				"CMAKE_BUILD_TYPE": "Debug"
            },
            "environment": {
            }
        },
        {
            "name": "linux_gcc",
            "hidden": false,
            "displayName": "Linux GCC",
            "description": "Default build using Unix Makefiles generator",
            "generator": "Unix Makefiles",
            "binaryDir": "${sourceDir}/out/build/${presetName}",
            "cacheVariables": {
                "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
                "CMAKE_C_COMPILER": "/usr/bin/gcc",
                "CMAKE_CXX_COMPILER": "/usr/bin/g++",
                "CMAKE_MAKE_PROGRAM": "/usr/bin/make",
                "CMAKE_BUILD_TYPE": "Debug"
            },
            "environment": {
            }
        }
    ],
    "buildPresets": [
        {
            "name": "mingw64",
            "displayName": "MinGW-w64",
            "configurePreset": "mingw64"
        },
        {
            "name": "linux_gcc",
            "displayName": "Linux GCC",
            "configurePreset": "linux_gcc"
        }
    ],
    "testPresets": [
        {
            "name": "mingw64",
            "displayName": "MinGW-w64",
            "configurePreset": "mingw64"
        },
        {
            "name": "linux_gcc",
            "displayName": "Linux GCC",
            "configurePreset": "linux_gcc"
        }
    ]
}

FAQs

Q. 如何输出MinGW-w64的C/C++内置宏

A. 打开CMD,运行以下命令

gcc -posix -E -dM - < nul

参考资料

SALOME

VS Code Multi-root workspaces

MSYS2

omniORB

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值