confounded

Hi,

For the following program and subsequent ones, I have had to add the miscellaneous compiler flag line (after the program) in order to get it to work (stop crashing on launch). I found the "fix" really by dumb luck. Does he "fix" mask any other potential problems?

Without the code fix I can't even publish "hello world" including cout(error).

1
2
3
4
5
6
7
8
9
10
11
#include<iostream>

using namespace std;

int main()
{
	std::cout<<"cout working fine"<<std::endl;

	return 0;
}


Fix:

-static-libgcc -static-libstdc++

successful launch
Are you using an IDE or are you using terminal? If you're using an IDE, it might be something wrong with your environment variable, where it's not giving you the correct build path to something like MinGW.
Last edited on
Make sure you use the g++ command when compiling C++ code. It is possible to use gcc too but then you need to pass additional flags to make it work.
Lot of words here - sorry -

Peter not sure what you mean, I use Eclipse Luna IDE for several years without invoking any sort of g++ command. Where do I find this and how do I change it. I think you are right though, I remember hearing something about if you are c/c++ programing you need to call g++ and not gcc.

Henry I just started using 64bit Eclipse Oxygen and and got some errors that when I am using my old Luna compiler on the new/updated 64bit files damage could occur. I did this once, which may have been all that was needed to corrupt stuff. I keep the files separate now and guess maybe I need to wean off of the 32 bit version. I think this 64bit version of Oxygen can compile 32bits in addition to 64 - maybe I need to move over completely.

The Eclipse Oxygen no problems like this at all. Just afraid of losing functionality of old files when I migrate.
Last edited on
It seems your IDE is using gcc rather than g++.

If the linker is invoked via gcc, it just links with the C runtime library. If the linker is invoked with g++m it additionally pulls in the C++ runtime library. The libraries you've listed are C++ runtime libraries.
Registered users can post here. Sign in or register to post.