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
。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
2022-10-10 关闭anaconda3 默认自动启动的命令
2022-10-10 github.com[0: 192.30.255.113]: errno=Connection refused
2022-10-10 centos7 中安装java8
2022-10-10 configure: error: HTSlib development files not found
2022-10-10 configure: error: htscodecs submodule files not present.
2022-10-10 utils.c:33:18: fatal error: zlib.h: No such file or directory
2021-10-10 ubuntu中root用户在图形界面登录