gpt4 book ai didi

c++ - CMake 不生成 .exe 文件

转载 作者:搜寻专家 更新时间:2023-10-31 02:11:54 25 4
gpt4 key购买 nike

我已经构建了一个基于 C++ 的 CERN 根脚本,并且我编写了(编辑示例)CMakeList.txt。顺便说一句,我对 CMake 很陌生。当我命令使用 cmake .. 进行编译时,它正确地完成了 - 我认为 - 没有错误。但是我想要生成的.exe 文件没有出现。我的目录命令

/Project
../TLV.cpp
../CMakeLists.txt
../build

这是我的 CMakeLists.txt

cmake_minimum_required(VERSION 2.8)
project(TLV)
#Set CXX flags to compile with c++11 and error warnings quiet
set(CMAKE_CXX_FLAGS "-O3 -fPIC -Wall -Wextra -std=c++11 -m64")

#Load root
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} $ENV{ROOTSYS}/etc/cmake)
#print conf
message(STATUS "Environmental CMAKE_MODULE_PATH is $ENV{ROOTSYS}")
#find the package with extra libraries needed
find_package(ROOT MODULE REQUIRED Cling TreePlayer Tree Rint Postscript Matrix RIO Core Foam RooStats RooFit RooFitCore Gpad Graf3d Graf Hist Net TMVA XMLIO MLP)
#include ROOT stuff
include(${ROOT_USE_FILE})
message(STATUS "Environmental ROOTSYS is $ENV{ROOTSYS}")
message(STATUS "found root at: ${ROOT_USE_FILE}")
message(STATUS "ROOT_LIBRARIES=${ROOT_LIBRARIES}")


#produce executables in bin path
set(EXECUTABLE_OUTPUT_PATH bin)
#include_directories(./../Framework Headers)
#${FROM_OTHERS_INCLUDE})
#defines all .cpp support class with corresponding Headers
#file(GLOB SRCS Sources/*.cpp Headers/*.hpp )
#${FROM_OTHERS_HEADER} ${FROM_OTHERS_SOURCE})

#add executable
add_executable( TLV TLV.cpp )

#link the executable with the root libraries
target_link_libraries(TLV ${ROOT_LIBRARIES})

我不明白哪里错了。

最佳答案

使用 cmake 的项目的典型场景是

cd src_directory   # for example  cd ~/src/root-6.08.06/
mkdir build # skip this if dir build already exists
cd build
cmake .. # the .. just says your source home dir is up a dir
cmake-gui .. # (optional) skip this unless you need a GUI alternative to cmake where you can edit settings
cmake --build # if you have a quad core CPU could use: make -j8 ... or make -j $(nproc) # on linux

然后启动二进制文件并确认它可以,然后如果需要安装它使用

sudo make install

关于c++ - CMake 不生成 .exe 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42881758/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com