When compiling in clion I get the error "executable is not specified"
Asked Answered
H

5

20

I'm using MacOS and trying to write c++ code in Clion but when I run the simple hello world code I get the error executable is not specified. I'm new to Clion.

Cmakelist.txt

cmake_minimum_required(VERSION 3.2)
project(untitled)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES main.cpp)
add_executable(untitled ${SOURCE_FILES})

clion

Heritage answered 6/5, 2015 at 19:49 Comment(7)
Since CLion is based on CMake, do you have an executable target in one of your CMakeLists.txt? If so, there should be an executable target you can run. This is of course me simply going off of memory from when CLion was still EAP.Transpadane
i added content of makelist.txt. And what does EAP stand for ? @TranspadaneHeritage
EAP simply means Early Access Program where you could use pre-released versions of CLion to try it out and report issues. Are there any other options in the Target dropdown other than "All targets"? It seems like you should have a target called untitled that would be an executable.Transpadane
where the option All targets ? How can I find @TranspadaneHeritage
I was referring to the "Target" dropdown in the screenshot you provided. Here is a link that provides more documentation about how to run and debug your code in CLion. jetbrains.com/clion/features/#run_and_debugTranspadane
that's it! untitled target i selected thank you @TranspadaneHeritage
Absolute fail. A "hello world" does not work. Sorry, there is no excuse. I know that there might an obvious fix those who are familiar with C tooling but I am a Java guy.Tebet
M
7

If you have created C/C++ Library by mistake, make sure that you make a new project with C/C++ executable. Then you will be able to debug it out of the box.

screenshot

Mattson answered 5/1, 2020 at 11:15 Comment(0)
G
5

I think CLion needs CMakeLists.txt for run/debug configuration. More info at: https://www.jetbrains.com/clion/help/cmakelists-file.html

As a C++ newbie, I have basically created new project in CLion then copy/past CMakeLists.txt content into my project by editing required fields.

After that, I was able to configure my project for run/debug.

Default CMakeLists.txt content should be something like this:

cmake_minimum_required(VERSION 3.3)
project(YourProjectName)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES YourSourceFile.cpp)
add_executable(YourProjectName ${SOURCE_FILES})

I hope this helps.

Gerek answered 10/3, 2016 at 19:17 Comment(0)
G
4

You just need choose target only for you application (choose your application name).

Like this enter image description here

Glutton answered 10/12, 2016 at 7:8 Comment(1)
This does not allow to build a static library either.Mastic
I
2

What I can tell from the original posts' image is that this build config is for a "c library" project type.

Solution: create a new project of type "c executable". When you launch this project, and hit run the application does run.

While this doesn't answer the question of whey the project type "c library" won't execute out of the box, it will get a newbie in business of tinkering with c.

I hope this helps.

Ilysa answered 25/11, 2019 at 0:36 Comment(0)
H
-1

image of what to click

click the left button “+” select “generate the coffee”

Hithermost answered 18/3, 2016 at 13:45 Comment(1)
click the left bottom “+” select “generate the coffeeScript source map”Hithermost

© 2022 - 2024 — McMap. All rights reserved.