Consider a variable abulo. I am trying to share abulo between 2 .c files. Here is what I did --
But when I try to run the code it shows me an output like this --
undefined reference to `abulo'
Tried to use the idea of the accpeted answer given here - How do I share variables between different .c files?
what am I doing wrong here ? How to get rid of this error ?
You should link a.o
when building the executable.
Example:
cc -c a.c
cc -c b.c
cc a.o b.o -o executable
# ^^^ this is important