C++ 在 CLion 中设置构建目标

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27801836/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 20:52:19  来源:igfitidea点击:

Setting build target in CLion

c++clion

提问by hintss

I'm trying to set up CLion (windows 8.1, 64-bit, using cygwin and not mingw), and I'm trying to compile+run a project, but I don't know what to do here:

我正在尝试设置 CLion(Windows 8.1,64 位,使用 cygwin 而不是 mingw),并且我正在尝试编译+运行一个项目,但我不知道在这里做什么:

enter image description here

在此处输入图片说明

It says I need a Target and a Configuration, but there're none in the dropdown. Is there a configuration step I missed?

它说我需要一个目标和一个配置,但下拉列表中没有。有没有我错过的配置步骤?

采纳答案by MondKin

At the end of your CMakeLists.txtyou should have a line that reads:

CMakeLists.txt你的最后你应该有一行写着:

add_executable(MyTarget ${SOURCE_FILES})

This line specifies the name of your target (the executable is generated with this name).

这一行指定了目标的名称(可执行文件是用这个名称生成的)。

If you don't have this line, add it and click on the "Reload changes" link at the top. This line should have been created when CLion created your project.

如果您没有此行,请添加它并单击顶部的“重新加载更改”链接。这一行应该是在 CLion 创建您的项目时创建的。

回答by MaC

Check in CMakeLists.txtthat the line set(SOURCE_FILES main.cpp ...does not reference files that does not exist. It solved it for me.

检查CMakeLists.txt该行set(SOURCE_FILES main.cpp ...是否引用了不存在的文件。它为我解决了它。

回答by hilo

I believe, the problem is, your Compiler/Cmake environment is not set. Check File/Settings/Build, Execution, Deployment/Toolchain setup before editing the configuration.

我相信,问题是,您的 Compiler/Cmake 环境未设置。在编辑配置之前检查文件/设置/构建、执行、部署/工具链设置。