You are using GCC wrongly. I guess you are on Linux (or on something emulating it like MinGW ...)
If you insist on giving several commands in a terminal, you'll need to run
gcc -Wall -Wextra -g -c stack.c
gcc -Wall -Wextra -g -c sq_main.c
these two commands are building object files stack.o
& sq_main.o
(from stack.c
& the #include
-d stack.h
, and sq_main.c
& the #include
-d stack.h
, respectively). The options -Wall -Wextra
are asking for all warnings and some extra warnings. The -g
option asks for debugging information. The -c
option asks for compiling only. Assuming that they are enough for your program, you need to link these object files to make an executable:
gcc -g stack.o sq_main.o -o myprogram
You might need to add -I
include-directory options to the compiling commands (the first two), and you might need to add -L
library-directory and -l
library-name to the linking command. Order of arguments to gcc
matters a lot. You could also add -H
to ask the compiler to show which files are included. And GCC has a lot of other options. Read the Invoking GCC chapter of its documentation.
The .o
suffix might be .obj
on most Windows systems. You might also need myprogram.exe
instead of myprogram
. I never used Windows so I cannot help more.
In practice, you should use GNU make
and write some Makefile
; this answer might inspire you.