Where does CLion store executable files?

C++CmakeUbuntu 14.04Jetbrains IdeClion

C++ Problem Overview


I install the CLion on a Ubuntu 14.04. I build my first project with help CMakeLists.txt:

Source file:

#include <iostream>
using namespace std;

int main() {
  cout << "Hello, World!" << endl;
  return 0;
}

CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.4)
project(sh)

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

My source file is located in a /home/user/Desktop/sh. But after build, I don't see any executable file in this folder. Where is it?

C++ Solutions


Solution 1 - C++

When you build under CLion,

enter image description here

It prints the path it sends the executable to the Console:

-- Build files have been written to: /home/<user>/.clion10/system/cmake/generated/8bd932b1/8bd932b1/Debug1

To change this File > Settings..., and under CMake settings, enter the desired subdirectory name (e.g., 'bin') in the Working directory field:

enter image description here

(You may require Run > Clean before the new output path is used.)

Solution 2 - C++

When you run the program, it shows the location at the top of the Run window:

/home/me/.clion10/system/cmake/generated/ad2f5c60/ad2f5c60/Debug/HelloCLion
Hello, World!

Process finished with exit code 0

You can modify this location by changing CMAKE_RUNTIME_OUTPUT_DIRECTORY:

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "/home/me/ClionProjects/Binaries")

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDenisView Question on Stackoverflow
Solution 1 - C++Brent FaustView Answer on Stackoverflow
Solution 2 - C++sfjacView Answer on Stackoverflow