Reputation: 589
I received 3 files from my teacher, main.c , something.c , something.h .
the header file contains the declarations of the functions. something.c contains the functions. main.c contains several calls to the functions.
my question is, how can i run main.c and have everything connected? in python i just import the module and im done (as long the file im importing is saved at the system variables directory or same directory).
thanks
Upvotes: 1
Views: 2513
Reputation: 337
You need to compile both something.c and main.c and link them together in one binary executable file. I don't know which OS are you supposed to run this on, if using Ubuntu, or any linux for that matter you could install gcc or clang to compile your code.
For example:
clang -c something.c main.c
clang something.o main.o
./a.out
First line compiles your files individually (creating main.o and something.o files) Second line links them together creating one executable file (a.out) Third line runs the executable file.
Upvotes: 3