Hey there, I have a small problem with compiling and linking with the command prompt(windows xp). Every .c file and .cpp file I compile or link has to be in the same directory as gcc (C:\Program Files\gcc\bin) and its quite hard to keep track of my files among all those gcc related files and its annoying too:). My question is how do I compile a file in a desktop folder using the command prompt?
usually I go:
c:\program files\gcc\bin> gcc -c test.c test2.c
when my source files are in bin.
What command do I use to compile When a file is situated elsewhere.
The GNU Compiler Collection (gcc)The GNU Compiler Collection, gcc, can compile programs written in C, C++, Java and several other languages. It provides many useful command line options and syntax extensions, and also serves as a powerful frontend for the GNU linker, ld.
Both are the compilers in Linux to compile and run C and C++ programs. Initially gcc was the GNU C Compiler but now a day's GCC (GNU Compiler Collections) provides many compilers, two are: gcc and g++. gcc is used to compile C program while g++ is used to compile C++ program.
DIFFERENCE BETWEEN g++ & gccg++ is used to compile C++ program. gcc is used to compile C program.
The GNU Compiler Collection, commonly known as GCC, is a set of compilers and development tools available for Linux, Windows, various BSDs, and a wide assortment of other operating systems. It includes support primarily for C and C++ and includes Objective-C, Ada, Go, Fortran, and D.
Right Click My COmputer. GO to properties. Go to advanced tab. There is a button below Environment Variables. Find "PATH" in the global environment variables. Add
c:\program files\gcc\bin
after appending the semicolon at the end of previous entry.
Add this c:\program files\gcc\bin
to PATH environment variable.
And then you can execute gcc/g++ from any directory
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With