Compile program in c++ for prompt of windows

Hello guys, i want compile my program in c++ for prompt, without use a IDE, but i can only if i put of program in folder of compiler that is minGW. For example:
code of program:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>

using namespace std;

int main()
{
	int a;
	cout << "Digite um numero ae: ";
	cin >> a;

	cout << "\nNumero digitado: " << a << endl;

	return 0;
}

And i put this line of command in prompt:

"cd mingw\\bin
g++ program.cpp -o file"
As the image:

http://postimg.org/image/79ptubwdf/

I want compile without need put of program in folder of compiler mingw, help me
Last edited on
Simply fully qualify the location of where your source file is:
g++ c:\fullpath\program.cpp -o file"
Thans AbstractionAnon, but when i want put many files, for example:
"g++ c:\Users\Lurdinha\Dropbox\Proj_Rodrigo\Gustavo\teste1\main.cpp heuristica.h heuristica.cpp rede.h rede.cpp detecta_ciclo.h detecta_ciclo.cpp -o file"

Look the image:

http://postimg.org/image/eokmfjqd3/
You probably need to specify the include path in the options you pass to the compiler.

EDIT: You're going to need to specify the full path for all your files, not just the first one.

Once a project starts containing several files, typing in compiler commands on the command line becomes a huge chore. If you're determined to do this stuff on the command line (which I don't understand; why forgo all the powerful features of a good IDE?) then you'll be much better off learning to use some kind of build system. Traditionally, makefiles are what people have used, or whatever the equivalent is on Windows (I've never been masochistic enough to do command-line programming on Windows, so I wouldn't know).

I'd also recommend looking into CMake. It's a system that can be used to create whatever build-system files you need for a given platform. You can use it to create Visual Studio projects on Windows, makefiles on Linux, etc.

Last edited on
Topic archived. No new replies allowed.