I have two C files (first file need another one).
I should use #include "XXX.C", but how I can make separately .obj files and then connect it (something like Borland’s Project)? I read something about link a, b command but it doesn’t work and I can’t find any reference.
Thank you!
You should not use #include “XXX.C”. If you want to compile it separately.
You have to write a “XXX.h” with all functions you want to call.
After that, you can compile the files separately:
If you want to compile and link in a single pass:
or if you want to compile xxx.c and use the object file previous generated:
or even:
In the last example, gcc would call the linker, as there is no source code to compile.
But if you have more than two or three files, the next thing to check is how to use a Makefile.
Example:
xxx.c:
yyy.c:
yyy.h:
Can be compiled separatelly:
In this example, xxx.c calls a function defined on yyy.c.