LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   source codes from different directories (https://www.linuxquestions.org/questions/programming-9/source-codes-from-different-directories-322836/)

crizcroz 05-12-2005 02:36 PM

source codes from different directories
 
Hello,

I try to combine the source code of two big c projects (with hundreds of files each). The c files have to remain in their directories. But how to invoke c code from other directories, is there a simple way to define that (at a certain point) the functions are to find in a completly different directory?

jtshaw 05-12-2005 02:38 PM

Typically the way you do this is by having include directories with the apporiate includes and adding them to the compile command (-I/blah/include) and when you need to link to object files together simply add the .o files to the compile command as well.

crizcroz 05-12-2005 02:43 PM

ooh, right! That might help :) I forgot about that, thanks!

crizcroz 05-12-2005 05:28 PM

Quote:

Originally posted by jtshaw
... and when you need to link to object files together simply add the .o files to the compile command as well...
is it really possible to link a .c file with an .o file, like:
Code:

gcc foo1.c foo2.o ...

crizcroz 05-13-2005 06:46 AM

anyone?

jtshaw 05-13-2005 06:50 AM

Quote:

Originally posted by crizcroz
is it really possible to link a .c file with an .o file, like:
Code:

gcc foo1.c foo2.o ...

Absolutely.... in my large projects I have an individual directory for serveral different components. There makefile's compile them with -c and generate .o files. I then link them all together with the main executable using exactly that syntax you described.


All times are GMT -5. The time now is 08:05 PM.