-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGCC COMMANDS.txt
executable file
·57 lines (35 loc) · 1.56 KB
/
GCC COMMANDS.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
To check whether GCC compiler is correctly installed
type the following command in the Command line
gcc --version {If you installed C compiler}
g++ --version {If you installed C++ compiler}
To Compile and link the program
cc program.c (generate default program name `a`)
gcc -o filename cprogam.c
or
gcc filename -o cprogram.c
// To check for error and warnings in the program, compile with options
cc filename -Wall
To See the output of the preprocessor use:
gcc cprogram.c -E
// In Linux, exe can be run (in current directry)
./a.out (where `a` is the default generated file)
To take input from file and write output to file. Use the following command:
For eg: For .txt files
program < input.txt > output.txt
When this command executes, it will read its standard input from the file `input.txt` instead of keyboard and it will write its
standard output to file `output.txt`.
To compile file from a directory (suppose `lib/some_function.c`, use like
cc sdf.c lib/some_functions.c (in linux and windows both)
or
cc sdf.c ./lib/some_functions.c (in linux only - above is preferred)
or
best use makefile
// Note, there is a `-B` option is not used for above. It's only used for search compiler files.
// Also, it can be use in place of `-L` or `-I`
/** We can also use `-L` option to set directory path (but this is only for libraries search not files)
cls --- clear the screen
cc (or gcc) -- for compiling program
cd.. ( one step back on previous folder)
dir (listing directories and files)
c: (or d: or any drive name)
cd foldername (move into that folder)