[Solus Linux][Clion] Clion doesn't compile the simplest program - c++

I downloaded Clion and all packages which I needed to work (I hope) and IDE doesn't compile "Hello World" program :(
Code:
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
Build errors:
https://pastebin.com/J5UA9HpX
Any ideas? Regards, Dziura.
Sorry for bad English

Related

GCC compiler does not output anything in Visual Studio Code or Atom

I try to compile this code
#include <iostream>
int main()
{
std::cout << "Hello World" << std::endl;
}
But it outputs
nothing in the terminal
Atom was just broken for me, had to restart my PC and Visual Studio Code started working.

missing output in the eclipse console when debugging

I recently started using Eclipse CDT (version 2019-03) with the Cygwin toolchain and have noticed some bizarre behaviour when using the debugger.
Under the debugger the following program behaves as you would expect
#include <iostream>
int main()
{
std::cout << "hello world\n" << std::flush;
}
However the following produces no output
#include <iostream>
int main()
{
std::cout << "* world\n" << std::flush;
}
And for the following the output is world
#include <iostream>
int main()
{
std::cout << "# world\n" << std::flush;
}
This behaviour is completely consistent and reproduceable. Does anyone have any explanation or workarounds?

Some more text showing up on console after debugging on VS 2017 Community

#include <iostream>
int main()
{
std::cout << "Hello World!" << std::endl;
return 0;
}
I was expecting to see only "Hello World" on the console after debugging. However, I see more stuff that distracts me, how can I fix that?
IMAGE:
http://prntscr.com/lt9jud

Why the IDE doesn't recognize my input?

Code
#include <iostream>
#include <curses.h>
#include <stdlib.h>
int main() {
std::cout << "Hello, World!" << std::endl;
std::cout << "Hello, World!";
return 0;
}
ALL instruction/text I insert become grey... I just installed CLion, maybe I'm missing something?
CLion greys out includes that aren't used in your code.
std::cout is from iostream (which isn't greyed out)
Try Building Ctrl + F9 and debugging Shift + F9 your code, you'll see your outputs
Hello, World!
Hello, World!
Process finished with exit code 0

What to do to see the output of "cout" command?

I am starting with C++ (Visual Studio 2015 and Windows 8.1), with this simple code:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world" << endl;
return 0;
}
But, the output screen shows nothing!, what shall I do?
Thanks in advance.
In Visual Studio, start the program with Ctrl-F5 and it will run and pause automagically for you. No additional code needed.
Your code is perfectly fine but the program currently only prints and exits right after, because this can happen very fast you might not be able to even see it,try pausing it :
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world" << endl;
cin.get();
return 0;
}
Also, make sure your Anti Virus isn't blocking Visual Studio.
Your code is just fine, however, if you execute it as a cmd program, the program window will close immediately, you might not be able to even see the output. You can write extra code to solve this problem by "pausing" the program:
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
cout << "Hello world" << endl;
system("PAUSE");
return 0;
}
if you don't like include a windows.h file every time you type, you can add a "cin.get();" in the end of the code. But to be honest, since you are just a beginner, the coolest way I think you should try, is not to use Visual Studio to learn C/C++ but to install CodeBlocks(a simple but effective IDE) to write some codes that are not so long. You know, VS is for huge and complex projects and some practical program developing.
Another solution, platform dependent. My answer is for those of you who just need test pause for debugging purposes. It's not recommended release solution!
windows
#include <iostream>
int main()
{
std::cout << "Hello world" << endl;
system("pause");
return 0;
}
linux (and many alternatives)
#include <iostream>
int main()
{
std::cout << "Hello world" << endl;
system("read -rsp $'Press enter to continue...\n'");
return 0;
}
Detecting paltform
I used to do this on programming homework assignments, ensuring this only happens on windows:
#include <iostream>
int main()
{
std::cout << "Hello world" << endl;
#ifdef _WIN32
system("pause");
return 0;
}
Here's a good cheatsheet for ifdef macros and operating systems: http://sourceforge.net/p/predef/wiki/OperatingSystems/
The program exits on return 0; and window closes. Before this, you must pause the program. E.g you can wait for an input.
Here is a snippet from my code to do this. It works in both windows and linux.
#include <iostream>
using std::cout;
using std::cin;
// Clear and pause methods
#ifdef _WIN32
// For windows
void waitForAnyKey() {
system("pause");
}
#elif __linux__
// For linux
void waitForAnyKey() {
cout << "Press any key to continue...";
system("read -s -N 1"); // Continues when pressed a key like windows
}
#endif
int main() {
cout << "Hello World!\n";
waitForAnyKey();
return 0;
}