freecad+geant4安装教程

目前FreeCAD现成版本是不可用的,通过源码编译进行撰写,其中官方安装有很多错误,Geant4+FreeCAD以79G的内存是不够用的,建议分配150G虚拟内存,安装方式如下:

我这里首先安装了FreeCAD 0.20 安d装步骤如下,源码加相关包超过4G的内容:

系统:Ubuntu 20.04:

1.安装git :sudo apt install git

2.下载源码:git clone https://github.com/FreeCAD/FreeCAD.git freecad-source

3.安装以下安装包:

sudo apt install cmake cmake-gui libboost-date-time-dev libboost-dev libboost-filesystem-dev libboost-graph-dev libboost-iostreams-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev libboost-serialization-dev libboost-thread-dev libcoin-dev libeigen3-dev libgts-bin libgts-dev libkdtree++-dev libmedc-dev libocct-data-exchange-dev libocct-ocaf-dev libocct-visualization-dev libopencv-dev libproj-dev libpyside2-dev libqt5opengl5-dev libqt5svg5-dev libqt5webkit5-dev libqt5x11extras5-dev libqt5xmlpatterns5-dev libshiboken2-dev libspnav-dev libvtk7-dev libx11-dev libxerces-c-dev libzipios++-dev occt-draw pyside2-tools python3-dev python3-matplotlib python3-pivy python3-ply python3-pyside2.qtcore python3-pyside2.qtgui python3-pyside2.qtsvg python3-pyside2.qtwidgets python3-pyside2.qtnetwork python3-pyside2.qtwebengine python3-pyside2.qtwebenginecore python3-pyside2.qtwebenginewidgets python3-pyside2.qtwebchannel python3-markdown python3-git python3-pyside2uic qtbase5-dev qttools5-dev swig

4.在上述安装包安装的过程中会有部分安装包会出错

  libvtk7-dev安装不成以libvtk6-dev替换

  python3-pyside2uic安装失败解决方式在以下网站,针对相关问题进行解决

       ubuntu and python3-pyside2uic - FreeCAD Forum (freecadweb.org)

5. mkdir freecad-build

6. cd freecad-build

7. cmake ../freecad-source

8. make -j$(nproc --ignore=2)

会出现VTK相关库报错问题解决方式,安装VTK的库,以下提供VTK7.1.1版本的安装方式:

    官方下载地址 https://www.vtk.org/download/

    安装依赖

     sudo apt-get install -y build-essential libgl1-mesa-dev libglew-dev libsdl2-dev libsdl2-image-dev libglm-dev libfreetype6-dev libglfw3-dev libglfw3

  1.tar -zxvf VTK-7.1.1.rc2.tar.gz

  2.mkdir vtk-build&& cd vtk-build

  3.cmake-gui

  4. 第一个是源码位置
      第二个是刚刚建的目录
      然后点configure

其他详细安装vtk以及本次安装教程查看百度网盘,博客园粘贴图像太费事了:

链接:https://pan.baidu.com/s/1W1V9M6rZet8rRmMOH3WDag?pwd=tclg
提取码:tclg

Geant4安装

sudo apt update

sudo apt upgrade

安装编译套件、vim、axel(多线程下载工具)

sudo apt install build-essential vim axel

安装Cmake

sudo apt-get install cmake

安装Qtcreator

sudo apt install qtcreator qtcreator-data qtcreator-doc

安装其他库、插件

sudo apt install libgl1-mesa-dev libglu1-mesa-dev mesa-common-dev libfontconfig1 libxt-dev libxmu-dev libxi-dev zlib1g-dev libgl2ps-dev libexpat1-dev libtbb-dev  libxerces-c-dev  qt5-default libmotif-dev  libtbb-dev libtinfo5

下载新的G4版本与对应的库文件

下载并安装CLHEP库    

tar -xvf clhep-2.4.1.3.tgz

#将解压出来的2.4.1.3 2.4.1.3 命名成CLHEP,并移动到work目录下

mkdir CLHEP-2.4.1.3-build

mkdir CLHEP-2.4.1.3-install

cd CLHEP-2.4.1.3-build

cmake -DCMAKE_INSTALL_PREFIX=/home/g4/work/CLHEP-2.4.1.3-install /home/g4/work/CLHEP-2.4.1.3

make -j4 #编译

make install

安装G4,添加G4相关库功能

tar -xvf geant4.10.06.p02.tar.gz

mkdir geant4.10.06.p02-build

mkdir geant4.10.06.p02-install

cd geant4.10.06.p02-build

cmake -DCMAKE_INSTALL_PREFIX=/home/g4/work/geant4.10.06.p02-install -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_BUILD_MULTITHREADED=ON -DGEANT4_USE_RAYTRACER_X11=ON -DGEANT4_USE_GDML=ON -DGEANT4_USE_XM=ON -DGEANT4_USE_SYSTEM_CLHEP=ON -DGEANT4_USE_QT=ON -DCLHEP_ROOT_DIR=/home/g4/work/CLHEP-2.4.1.3-install -DCLHEP_INCLUDE_DIR=/home/g4/work/CLHEP-2.4.1.3-install/include -DCLHEP_LIBRARY=/home/g4/work/CLHEP-2.4.1.3-install/lib /home/g4/work/geant4.10.06.p02

make -j4  #编译 -前面有空格

make install

需要新建data文件夹,将数据文件放在/home/g4/work/geant4.10.06.p02-install/share/Geant4-10.6.2/data

ls *.tar.gz | xargs -n1 tar xvf  

/home/g4/work/geant4.10.06.p02-install/share/Geant4-10.6.2/data

添加geant4的环境变量

vim ~/.bashrc

source /home/g4/work/geant4.10.06.p02-install/share/Geant4-10.6.2/geant4make/geant4make.sh

:q #退出来

source ~/.bashrc

安装root

下载root的编译好的包

解压安装包

vim ~/.bashrc

source /home/g4/work/root/bin/thisroot.sh

:wq #退出来

source ~/.bashrc

posted @ 2022-06-27 15:44  Ace-GJH  阅读(440)  评论(0编辑  收藏  举报