Thursday, July 9, 2009

Compiling 2 source code files?

So I'm using the GNU C compiler on linux and if I have 2 files (call them file1.c and file2.c) to compile them together I would do gcc file1.c file2.c right? but then how would I execute that? To execute one file I would just do gcc file1.c and then ./file1... but how do I execute 2 files (1 of which is dependent on the other)?

Compiling 2 source code files?
gcc file1.c file2.c -o myprogram


./myprogram





The -o flag sets the output file.
Reply:im no genius but i would say that the program that is dependent upon the other you should link the program source code to execute the other. Don't ask me how to do it as i don't use c that much anymore


No comments:

Post a Comment