How do I send my CLion's output to the Gnome Terminal on Debian?
In the "Run/Debug Configurations" dialog
and change the executable to any custom executable, like for example the gnome terminal and then pass the your program as an argument:
Note that once your program exits or returns from main
then the terminal will close as well.
How do i open a program in a separate terminal from c++ code?
Beside the fact that there might be more elegant solutions than invoking a terminal via C++ to execute a programm you could go with one of these:
std::string
The most obvious solution is to use std::string
which provides the overloaded operator +
to concat strings.
#include <string>
std::string args = "gnome-terminal ";
args += "-e 'sh ./spout";
args += "' ";
std::stringstream
std::stringstream
is another option:
#include <sstream>
#include <string>
std::stringstream ss;
ss << "gnome-terminal ";
ss << "-e 'sh ./spout";
ss << "' ";
std::string args = ss.str();
strcat()
If you want to use C strings you can use something like this. Note that I do not recommend this.
#include <cstring>
strcpy(args, "gnome-terminal");
strcat(args, "-e 'sh ./spout");
strcat(args, "' ");
Please note, that the second version needs a closer look at the allocated memory for args
. See strcat() for further information.
CLion - Where is my output?
CLion uses a separate directory for building and uses that as the "current directory" when running your programs.
For me working on a Linux system the directory is ~/.CLion2016.2/system/cmake/generated/project-name-<digits>
.
If you want another directory, like your actual project directory, then I suggest you edit the "Run/Debug Configurations" for the program, and explicitly set the "Working directory" to the directory you want.
See Creating and Editing Run/Debug Configurations for more information.
Related Topics
Fastest Way to Produce a Mask with N Ones Starting at Position I
Check If a Type Is Passed in Variadic Template Parameter Pack
Is the Comma in a Variable List a Sequence Point
How Is Floating Point Conversion Actually Done in C++(Double to Float or Float to Double)
How to Decide If a Template Specialization Exist
Clang-Omp in Xcode Under El Capitan
Fun with Uninitialized Variables and Compiler (Gcc)
Concatenate Char Arrays in C++
How to Print Boost::Any to a Stream
Are Non Dereferenced Iterators Past the "One Past-The-End" Iterator of an Array Undefined Behavior
How to Read from Memory Just Like from a File Using iOStream
Why Do I Need to Include Both the iOStream and Fstream Headers to Open a File
Eclipse Mingw C++ Cannot Find -Lpthread