LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-12-2005, 02:36 PM   #1
crizcroz
LQ Newbie
 
Registered: May 2005
Location: Berlin
Distribution: Gentoo
Posts: 4

Rep: Reputation: 0
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?
 
Old 05-12-2005, 02:38 PM   #2
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
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.
 
Old 05-12-2005, 02:43 PM   #3
crizcroz
LQ Newbie
 
Registered: May 2005
Location: Berlin
Distribution: Gentoo
Posts: 4

Original Poster
Rep: Reputation: 0
ooh, right! That might help I forgot about that, thanks!
 
Old 05-12-2005, 05:28 PM   #4
crizcroz
LQ Newbie
 
Registered: May 2005
Location: Berlin
Distribution: Gentoo
Posts: 4

Original Poster
Rep: Reputation: 0
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 ...
 
Old 05-13-2005, 06:46 AM   #5
crizcroz
LQ Newbie
 
Registered: May 2005
Location: Berlin
Distribution: Gentoo
Posts: 4

Original Poster
Rep: Reputation: 0
anyone?
 
Old 05-13-2005, 06:50 AM   #6
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error when building source codes... darkarcon2015 Linux - Software 4 12-21-2004 11:39 PM
where should I install source codes jaakkop Linux - Software 4 11-12-2004 10:24 AM
installing source codes minm Linux - Newbie 4 09-15-2004 03:03 PM
Linux Command Source Codes GodSendDeath Slackware 1 03-12-2004 03:12 AM
source codes eltongeoff Linux - Newbie 3 12-07-2003 05:17 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration