cmake、make、make install命令应用案例

 

以bamtools软件为例。

001、 解压该软件

[root@pc1 software]# ls                                         ## 列出安装包      
bamtools-2.5.2.zip  cmake-3.27.7
[root@pc1 software]# unzip bamtools-2.5.2.zip &> /dev/null      ## 解压该软件
[root@pc1 software]# ls
bamtools-2.5.2  bamtools-2.5.2.zip  cmake-3.27.7
[root@pc1 software]# cd bamtools-2.5.2/                         ##  进入安装目录
[root@pc1 bamtools-2.5.2]# ls                                   
CMakeLists.txt  docs  LICENSE  README  src  tests

 

002、 执行cmake

[root@pc1 bamtools-2.5.2]# ls
CMakeLists.txt  docs  LICENSE  README  src  tests
[root@pc1 bamtools-2.5.2]# cmake CMakeLists.txt                ## cmake 作用 于cmakelists.txt, 生成makefile
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The CXX compiler identification is GNU 4.8.5
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.27.1")
-- Checking for one of the modules 'jsoncpp>=1'
Did NOT find system JsonCpp, instead using bundled version
-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.7")
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Configuring done (0.4s)
-- Generating done (0.0s)
-- Build files have been written to: /home/software/bamtools-2.5.2
[root@pc1 bamtools-2.5.2]# ls         ## 列出文件
CMakeCache.txt  cmake_install.cmake  CTestTestfile.cmake    docs     Makefile  src      tests
CMakeFiles      CMakeLists.txt       DartConfiguration.tcl  LICENSE  README    Testing

 

003、 执行make

[root@pc1 bamtools-2.5.2]# make -j 6        ## make编译, -j指定线程数

 

004、找到可执行程序

[root@pc1 bamtools-2.5.2]# ls                 ##  列出内容
CMakeCache.txt  cmake_install.cmake  CTestTestfile.cmake    docs     Makefile  src      tests
CMakeFiles      CMakeLists.txt       DartConfiguration.tcl  LICENSE  README    Testing
[root@pc1 bamtools-2.5.2]# cd src/            ## 进入src目录
[root@pc1 src]# ls
api       bamtools-1.pc   bamtools_version.h  cmake_install.cmake  libbamtools.a        Makefile  third_party  utils
bamtools  bamtools.pc.in  CMakeFiles          CMakeLists.txt       libBamTools-utils.a  shared    toolkit
[root@pc1 src]# ./bamtools --version          ## 本地调用测试软件

bamtools 2.5.2
Part of BamTools API and toolkit
Primary authors: Derek Barnett, Erik Garrison, Michael Stromberg
(c) 2009-2012 Marth Lab, Biology Dept., Boston College

[root@pc1 src]# bamtools --version            ## 测试是否在环境变量中
bash: bamtools: command not found...

 

005、执行make install命令

[root@pc1 src]# ls
api       bamtools-1.pc   bamtools_version.h  cmake_install.cmake  libbamtools.a        Makefile  third_party  utils
bamtools  bamtools.pc.in  CMakeFiles          CMakeLists.txt       libBamTools-utils.a  shared    toolkit
[root@pc1 src]# cd ..       ## 返回到makefile文件所在的同一级目录
[root@pc1 bamtools-2.5.2]# ls       ## 列出文件内容
CMakeCache.txt  cmake_install.cmake  CTestTestfile.cmake    docs     Makefile  src      tests
CMakeFiles      CMakeLists.txt       DartConfiguration.tcl  LICENSE  README    Testing
[root@pc1 bamtools-2.5.2]# make install     ## 执行make install
[ 63%] Built target BamTools
[ 72%] Built target BamTools-utils
[ 75%] Built target jsoncpp
[100%] Built target bamtools_cmd
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib64/libbamtools.a
-- Installing: /usr/local/bin/bamtools        ## 按照到了默认目录
-- Installing: /usr/local/include/bamtools/api/BamAlgorithms.h
-- Installing: /usr/local/include/bamtools/api/BamAlignment.h
-- Installing: /usr/local/include/bamtools/api/BamAux.h
-- Installing: /usr/local/include/bamtools/api/BamConstants.h
-- Installing: /usr/local/include/bamtools/api/BamIndex.h
-- Installing: /usr/local/include/bamtools/api/BamMultiReader.h
-- Installing: /usr/local/include/bamtools/api/BamReader.h
-- Installing: /usr/local/include/bamtools/api/BamWriter.h
-- Installing: /usr/local/include/bamtools/api/IBamIODevice.h
-- Installing: /usr/local/include/bamtools/api/SamConstants.h
-- Installing: /usr/local/include/bamtools/api/SamHeader.h
-- Installing: /usr/local/include/bamtools/api/SamProgram.h
-- Installing: /usr/local/include/bamtools/api/SamProgramChain.h
-- Installing: /usr/local/include/bamtools/api/SamReadGroup.h
-- Installing: /usr/local/include/bamtools/api/SamReadGroupDictionary.h
-- Installing: /usr/local/include/bamtools/api/SamSequence.h
-- Installing: /usr/local/include/bamtools/api/SamSequenceDictionary.h
-- Installing: /usr/local/include/bamtools/api/api_global.h
-- Installing: /usr/local/include/bamtools/api/bamtools_api_export.h
-- Installing: /usr/local/include/bamtools/api/algorithms/Sort.h
-- Installing: /usr/local/include/bamtools/shared/bamtools_global.h
-- Installing: /usr/local/lib64/pkgconfig/bamtools-1.pc

 

006、测试环境变量

[root@pc1 bamtools-2.5.2]# bamtools --version             ## 测试环境变量,可以直接调用;说明make install动作实现了在安装到环境变量所在目录

bamtools 2.5.2
Part of BamTools API and toolkit
Primary authors: Derek Barnett, Erik Garrison, Michael Stromberg
(c) 2009-2012 Marth Lab, Biology Dept., Boston College

[root@pc1 bamtools-2.5.2]# echo $PATH                     ## 输出环境变量
/usr/local/cmake_new/bin:/usr/local/cmake_new/bin/root/anaconda3/bin:/usr/local/cmake_new/bin/root/anaconda3/bin:/root/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

 

 

posted @ 2023-10-10 20:07  小鲨鱼2018  阅读(82)  评论(0编辑  收藏  举报