首页 > 系统相关 >ubuntu20.4安装geant4和root

ubuntu20.4安装geant4和root

时间:2023-06-14 18:12:38浏览次数:36  
标签:opt ubuntu20.4 sudo include Geant4 geant4 root

1.下载需要的软件包和数据包

下载root

https://root.cern/install/all_releases

 

 

下载geant4

https://geant4.web.cern.ch/download/all

 

 

2.准备安装文件

在home目录下面创建一个geant4的文件夹

打开geant4文件夹,在里面创建一个file的文件夹

将下载好的14个文件拖动到这个文件夹(home目录下的/geant4/file/)下

右击终端打开

cd ~

 

将刚刚传入的文件移动到opt目录下

sudo mv geant4/ /opt/

 

进入下载的文件的文件夹目录

cd /opt/geant4/file/

 

移动下载的geant4-v11.1.1.tar.gz到上级目录

sudo mv /opt/geant4/file/geant4-v11.1.1.tar.gz ..

 

返回上一级

cd ..

 

解压

sudo tar -zxvf geant4-v11.1.1.tar.gz

 

删除安装包

sudo rm -rf geant4-v11.1.1.tar.gz

 

3.安装依赖

安装依赖工具

sudo apt install curl g++ libgl1-mesa-dev cmake libx11-dev libxext-dev libxtst-dev libxrender-dev libxmu-dev libxmuu-dev libhdf5-serial-dev hdf5-tools libexpat1 libexpat1-dev build-essential -y

 

安装qt5

sudo apt install qt5* -y

 

创建两个文件夹

mkdir geant4-install
mkdir geant4-build && cd geant4-build

 

4.安装geant4

sudo cmake -DCMAKE_INSTALL_PREFIX=/opt/geant4/geant4-install \
-DGEANT4_USE_OPENGL_X11=ON \
-DGEANT4_USE_RAYTRACER_X11=ON \
-DGEANT4_USE_QT=ON \
GEANT4_BUILD_MULTITHREADED=ON \
/opt/geant4/geant4-v11.1.1

 

ps:-jN表示应用的电脑逻辑处理器数

sudo make -j6

 

进行安装

sudo make install -j6

 

设置环境变量

echo "source /opt/geant4/geant4-install/bin/geant4.sh" >> ~/.bashrc

 


5.安装geant4的数据包

进入下载的文件的文件夹目录

cd /opt/geant4/file/

 

创建data文件夹

mkdir -p /opt/geant4/geant4-install/share/Geant4/data

 

移动数据包到geant4的安装目录下

sudo mv G4*.tar.gz /opt/geant4/geant4-install/share/Geant4/data

 

然后在data文件夹下批量解压

cd /opt/geant4/geant4-install/share/Geant4/data
sudo ls *.tar.gz | sudo xargs -n1 tar xzvf

 

geant4的数据包已经安装完成,删除数据包

sudo rm -rf G4*.tar.gz

 

使环境变量生效

source ~/.bashrc

 

6.安装root

右击终端打开

进入下载的文件的文件夹目录

cd /opt/geant4/file/

 

解压即可使用 - 在Ubantu系统中解压的命令

sudo tar -zxvf root_v6.28.04.Linux-ubuntu20-x86_64-gcc9.4.tar.gz

 

移动到opt目录下

sudo mv root /opt/

 

删除安装包

sudo rm -rf root_v6.28.04.Linux-ubuntu20-x86_64-gcc9.4.tar.gz

 

配置环境变量

echo "source /opt/root/bin/thisroot.sh" >> ~/.bashrc

 

使环境变量生效

source ~/.bashrc

 

ps之后每次想要用root的时候可以直接使用,更加方便。

验证root

root

 


7.验证安装

右击终端打开

建立工作路径

mkdir ~/geant4_ws && cd ~/geant4_ws

 

将官方例子复制到工作路径里面

cp -r /opt/geant4/geant4-install/share/Geant4/examples ~/geant4_ws
cp -r ~/geant4_ws/examples/basic/B1 ~/geant4_ws
cd B1
mkdir build && cd build

 

下面的命令cmake后面是空格加两个点(表示用上级目录进行cmkae)

cmake ..

 

出错的话执行 source ~/.bashrc

编译运行

make -j6

 

./exampleB1

 

 8.vscode中配置geant4和root

打开vscode

安装插件Chinese、C/C++、CMake Tools

在geant4_ws目录下新建一个文件夹G4_First

在vscode中打开文件夹,新建include,src,build文件夹

按住Ctrl+Shift+P,搜索框中输入c++,点击"编辑配置(JSON)"

修改json文件内容如下

{
    "configurations": [
        {
            "name": "Linux",
            "browse": {
                "path": [
                    "${workspaceFolder}/src",                       //链接source
                    "${workspaceFolder}/include",                   //链接include
                    "/opt/root/include",                            //链接root
                    "/opt/geant4/geant4-install/include/Geant4"     //链接Geant4头文件
                ],
                "limitSymbolsToIncludedHeaders": true
            },
            "includePath": [
                "${workspaceFolder}/src",                       //链接source
                "${workspaceFolder}/include",                   //链接include
                "/opt/root/include",                            //链接root
                "/opt/geant4/geant4-install/include/Geant4"     //链接Geant4头文件
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c17",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

 

新建文件Hello.cc

int main(void){
   return 0;
}

 

新建文件CMakeLists.txt

在文件中填入以下内容保存

#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 3.16...3.21)
# 工程名称G4_First project(G4_First) #---------------------------------------------------------------------------- # Find Geant4 package, activating all available UI and Vis drivers by default # You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui # to build a batch mode only executable # option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON) if(WITH_GEANT4_UIVIS) find_package(Geant4 REQUIRED ui_all vis_all) else() find_package(Geant4 REQUIRED) endif() #---------------------------------------------------------------------------- # Setup Geant4 include directories and compile definitions # Setup include directory for this project # include(${Geant4_USE_FILE}) include_directories(${PROJECT_SOURCE_DIR}/include) #---------------------------------------------------------------------------- # Locate sources and headers for this project # NB: headers are included so they will show up in IDEs # file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc) file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)

#----------------------------------------------------------------------------
# Add the executable, and link it to the Geant4 libraries
#工程名G4_First,主文件Hello.cc
add_executable(G4_First Hello.cc ${sources} ${headers})
target_link_libraries(G4_First ${Geant4_LIBRARIES})



 

打开终端

cd build && cmake ..
make -j6
./G4_First

 

标签:opt,ubuntu20.4,sudo,include,Geant4,geant4,root
From: https://www.cnblogs.com/endcase/p/17481014.html

相关文章

  • goland提示GOROOT is not defined
    场景,今天在新电脑使用goland,打开goland,没有加载GOROOT1.先检查GOROOT和GOPATH等配置是否已经加到系统环境变量中,如果没有加,那么就加一下2.跟着Goland提示进入到配置项中,选择goland安装目录又提示TheselecteddirectoryisnotavalidhomeforGoSdk那么接下来就需要改一......
  • (2023.6.12)buildroot交叉编译第三方库
    编译链没有精确到bin目录Buildroot下没有dl文件夹(编译之后才有;新的第三方库,文件夹如何命名?) 修改profile,使用build_root重新编译??(重新打包就行)新的第三方库源码如何配置编译参数?......
  • 【Ubuntu22.04】安装MySQL数据库,修改root用户密码,实现远程访问,
    预备条件本次实验使用静态IP的地址192.168.1.81作为mysql-001服务器地址,并配置为本地域名mysql-001:打开Powershell(Window自带)使用SSH方式连接服务器,用户名test,密码:123456:安装Mysql:更新软件源aptupdate安装MySQL8.0,因为Ubuntu22.04不支持MySQL5.7sudoaptinst......
  • RK3568开发板Buildroot 系统设置显示颜色格式
    BuildrootSDK内Weston目前默认显示格式为ARGB8888,对于某些低性能平台,可以在weston.ini的core段配置为RGB565。修改文件系统中/etc/xdg/weston/weston.ini文件,修改如下所示:[core]#xrgb8888|rgb565|xrgb2101010gbm-format=rgb565也可以在weston.ini的output段单独配......
  • 使用外置存储设备扩展exroot(MT1300)
    环境说明:GL-INETMT1300设备一台8GU盘一个,已经格式化文件系统为EXT41.安装相关工具opkgupdateopkginstallblock-mountkmod-fs-ext4e2fsprogsfdisk 2.修改fstab配置文件,更改现有文件系统的挂载点DEVICE="$(sed-n-e"/\s\/overlay\s.*$/s///p"/etc/mtab)"uci-q......
  • [Vue warn]: Error compiling template: Component template should contain exactly
    报错信息:[Vuewarn]:Errorcompilingtemplate:Componenttemplateshouldcontainexactlyonerootelement.Ifyouareusingv-ifonmultipleelements,usev-else-iftochaintheminstead.2|3|4||......
  • CentOS7 修改root的开机登陆密码+忘记root密码如何修改root密码
    一、修改root的开机登陆密码[root@TS004~]# passwd  //*更改当前的root用户密码命令ChangingpasswordforuserrootNewpassword:    //*(输入新密码,密输入的密码不会显示)Retypenewpassword:     //*(确认输入新密码,密输入的密码不会显示)passwd:allauthe......
  • ubuntu20.4安装geant4和root
    #下载需要的软件包和数据包下载roothttps://root.cern/install/all_releases 下载geant4https://geant4.web.cern.ch/download/all#在家目录下面创建一个geant4的文件夹#打开geant4文件夹,在里面创建一个file的文件夹#将下载好的14个文件拖动到这个文件夹(家目录下的/gean......
  • amazon linux 2 重置root密码
    amazonlinux2重置root密码linux的版本很多,但是重置root用户的密码的方法都是相似的,都是进入单用户模式修改root密码。步骤1.重启amazonlinux2重启amazonlinux2服务器后,进入系统加载页面2.按键盘“e”键,进入编辑模式3.移动光标找到linux16开头的那行,将光标移动到该行的末......
  • 2023-06-06:给你二叉树的根结点 root ,请你设计算法计算二叉树的 垂序遍历 序列。 对位
    2023-06-06:给你二叉树的根结点root,请你设计算法计算二叉树的垂序遍历序列。对位于(row,col)的每个结点而言,其左右子结点分别位于(row+1,col-1)和(row+1,col+1)树的根结点位于(0,0)。二叉树的垂序遍历从最左边的列开始直到最右边的列结束,按列索引每一列上......