I tried to compile my C++ source ( simple hello world ) on WSL Linux through VS2019 after installed g++ gdb packages in Ubuntu WSL, I could debug the code and get info on vs2019 env but when try to built it I get below error
( Maybe a manual how this remote, WSL Linux compiling work )
Object reference not set to an instance of an object.
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <cmath>
using namespace std;
inline void keep_window_open() { char c; cin >> c; }
int main()
{
cout << "hello from ConsoleApplicationC__!\n";
keep_window_open();
return 0;
}```
Related
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
Can someone explain what is happening here?
#include <iostream>
#include <string>
using namespace std;
int main() {
string kek = "kek";
cout << "test" << endl;
return 0;
}
For some reason, every time I compile with g++, and I declare a string variable, I can't see any output, no compile or runtime errors, simply no output.
Now, if I change the code to be this instead:
#include <iostream>
#include <string>
using namespace std;
int main() {
// string kek = "kek";
cout << "test" << endl;
return 0;
}
then everything works.
Does anyone know what the problem is here?
I am currently on Windows 10, using gcc 8.1.0.
Edit:
same thing but using bash, linux compile
i think the version of mingw i had is bugged so trying to reinstall it
Okay so still i have no idea what that bug was about,
but when i had it, the version of MinGW i had was 32bit,
changing the MinGW installation to 64bit, fixed that issue.
i have changed nothing, except removing MinGW 32bit from my comp,
and setting the MinGW 64bit.
Swaping from MinGW 32bit to 64bit, fixed the issue.
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?
I have a C++ program which I am compiling on a x64 machine running Windows 10 with g++ x86_64-win32-seh-rev2 v7.1.0, using the command g++ -g main.cpp. When I run my program, I get the error 0xc000007b. This is my code
#include <iostream>
using namespace std;
int main() {
cout << "Hello World";
return 0;
}
When I compile with this code
#include <stdio.h>
using namespace std;
int main() {
printf("Hello World");
return 0;
}
It works fine. When I run it in gdb, it runs fine.
I have seen other posts where there are dlls being used that do not support the architecture, but I don't think I am using any dlls in this application, unless they are being added by g++
I installed Netbeans and as C++ compiler I installed cygwin. I made a simple project to test out my installation, this is the code:
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
cout << "test";
return 0;
}
This is the error message that it gives: http://pastebin.com/jRRh7MPi
I hope you guys can help me out.
You need to either explicitly link to C++ standard library, or compile using g++ instead of gcc.