1

I have recently installed Clion student version and I get the error executable not found whenever I try to run my code. I installed cygwin with it as specified on their website and also, respective packages as required. Here's how my tool chains window looksCygwin is installed and works properly

Here is my cmakelists.txt file

cmake_minimum_required(VERSION 3.8)
project(coding)

set(CMAKE_CXX_STANDARD 11)

set(SOURCE_FILES library.cpp library.h)
add_library(coding ${SOURCE_FILES})

Here is the error that I get: Executable not specified

I do not see any options in the executables list.I am using Windows 10.

What do I do?

krishna
  • 405
  • 6
  • 25
  • Your CMake project builds only a library, which cannot be run by definition. So, what do you want from CLion to do on "Run"? – Tsyvarev Aug 15 '17 at 21:23
  • I am just trying to run the hello world program. All those files were auto generated. – krishna Aug 15 '17 at 21:31

2 Answers2

0

Check out this answer.

SHORT ANSWER (should be similar for MinGW too but I haven't tried it):

  1. Install Cygwin with GCC, G++, GDB and CMake (the required versions)
  2. Add full path to Cygwin 'bin' directory to Windows Environment variables
  3. Restart CLion and check 'Settings' -> 'Build, Execution, Deployment' to make sure CLion has picked up the right versions of Cygwin, make and gdb
  4. Check the project configuration ('Run' -> 'Edit configuration') to make sure your project name appears there and you can select options in 'Target', 'Configuration' and 'Executable' fields.
  5. Build and then Run
  6. Enjoy

EDIT:

Looking more closely at the screenshot, it looks like you are actually making a C++ library in which case you wouldn't have an executable and it can not be run - a library is compiled and then used in another application.

Austin Yates
  • 108
  • 9
0

Note: As this is a very basic question which may confuse beginners coding in CLion IDE, I'm putting this thorough answer here to stay as a step by step guide.

It seems you've selected C++ Executable when first creating the project. As CLion heavily depends on CMake (& thus CMakeLists.txt), you can change the project type from a C++ Library to C++ Executable. To do this, replace the following line:

add_library(coding ${SOURCE_FILES})

with:

add_executable(coding ${SOURCE_FILES})

Afterwards, select the desired file to execute from the "Executable" combo-box in "Edit Configuration" dialogue.

Now you're done. But if you wanna make your project clean, you may follow these steps to make it a pure executable project (rather being a library one):

  1. remove the library.h from set(SOURCE_FILES library.cpp library.h) in CMakeLists.txt file.
  2. remove the #include "library.h" from the beginning of library.cpp file.

Now your project seems like it was first created as a C++ Executable project.

behkod
  • 2,647
  • 2
  • 18
  • 33