Eclipse CDT using std libraries in external console - c++

I created C++ console project in Eclipse on Windows 7. I wanted it to run in external terminal, so I configured External Tool as described here: LINK. The following code runs fine and shows "Hello" on the console:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
void foo() {
//queue<char> x;
}
int main() {
//vector<int> a;
//string t;
cout << "Hello World!" << endl;
cin.get();
return 0;
}
However, when I uncomment one of the lines above, external console refuses to work (program exits instantly). Program compiles successfully and runs in the internal console.
The variables do not have to be used, declaration is sufficient to stop excution. I assume, there is something wrong with the External Tool, as the internal console works normally (maybe I should add some libraries to working directory).
Any ideas?

Related

Just installed visual studio; 478 of "E0282 the global scope has no..." errors when compiling C++ program

I'm trying to run a program that prints out "hello" just to see if I can get C++ to run on my machine (running Windows 10 Home and Visual Studio 17.0.5). When I compile the program, I get all kinds of errors that seem to point to files that I haven't even included in my program:
#include <iostream>
#include <string>
using namespace std;
int main() {
cout << "hello";
return 0;
}
screenshot of errors

When the program built with C::B doesn't work

I made a small c++ project and it was fully compiled and built it.
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
When I run through c::b it was okay
However, it says next warnings when I run program outside of the c::b.
"programdir/bin/Debug/program.exe"
So I got "libgcc_s_dw2-1.dll" from sourceforge, pasted it next to my .exe file,
and I got 0xc000007b error with the error "cannot start the program"
What should I do in this case of problem?

Visual Studio 2017 "Unable to start program. The system cannot find the file specified"

I'm following this tutorial to create a C++ Hello World app for Visual Studio.
https://tutorials.visualstudio.com/cpp-console/install
I've installed the software, selected "Windows Console Application" and copy/pasted the Hello World program from the tutorial:
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, world!\n";
return 0;
}
However, when I try to run the Local Windows Debugger, I get this error:
Unable to open program.
\repos\HelloWorld\Debug\HelloWorld.exe
The system cannot find the file specified.
How would I include an .exe file?
Also, I have an error "cannot open stdafx.h", but I assume that's connected to this.
EDIT:
I removed "#include "stdafx.h"" and got the same error. It also said there was an unexpected end of file and suggested I #include "pch.h", so I did.
#include <iostream>
#include "pch.h"
using namespace std;
int main()
{
cout << "Hello, world!\n";
return 0;
}
I'm still getting the error that it can't find .exe ...also 'cout' is an undeclared identifier.

CLion finds a wrong function signature

I constantly have CLion editor showing me parameter type mismatch errors while during build everything is fine. For example, consider the following MWE:
#include <iostream>
#include <boost/container/flat_set.hpp>
using namespace std;
namespace bc = boost::container;
int main() {
bc::flat_set<bc::flat_set<int>> manySets;
bc::flat_set<int> oneSet({1, 2, 3});
manySets.insert(oneSet);
cout << "Hello, World!" << endl;
return 0;
}
Here flat_set is a template from boost library (description could be seen here). Editor shows me an error:
But when I build it (even from CLion), everything is compiled fine.
My system is:
Ubuntu 15.10 64bit
CLion 1.2.4
This looks like a known problem - https://youtrack.jetbrains.com/issue/CPP-6027. We hope to fix it soon.

build does not stop in Visual Studio 2010

I try to build a simple piece of code in Visual Studio, but the building process gets entangled in an infinite loop.
The code is simple:
// test.cpp : Defines the entry point for the console application.
//
#include <iostream.h>
using namespace std;
int main(void)
{
cout << "Hi." << endl;
return 0;
}
Any idea what is going on?
Thanks.
spot several things:
not sure what's in 'stdafx.h'
#include < iostream >
std::cout, std::endl (unless using namespace std; somewhere)
Build works fine for me, though.