使命令不产生可执行文件

Make command not producing an executable file

本文关键字:可执行文件 命令 使命      更新时间:2023-10-16

我刚刚开始使用C ,并想使用CMake编译简单的Hello World程序,但是一旦生产了Makefile,我不知道该如何处理。我有一个名为Tutorial的目录,其中包含我的tutorial.cpp文件,其中包含Hello World Code。我也有一个包含:

的cmakelists文件
cmake_minimum_required(VERSION 3.14.4)
project (tutorial)
add_executable(tutorial tutorial.cpp)

当我从终端中的教程目录运行命令cmake .时,所有正确的(至少我认为它们是正确的(文件,我将获得以下输出:

-- The C compiler identification is AppleClang 10.0.1.10010046
-- The CXX compiler identification is AppleClang 10.0.1.10010046
-- Check for working C compiler:             
/Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: 
/Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler:     
/Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: 
/Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to:     
/Users/kshitijsachan/Documents/cs/cpp/tutorial

i然后在终端中输入make,没有输出。我该如何实际运行生产的makefile?

运行 make <some_valid_target_name>-例如 make allmake install(如果存在这种常用的目标(或项目定义的任何其他目标。查看您的项目文档或cmakelists.txt文件中的有效目标名称。

另请参见添加目标的cmake_add_executable。