Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Best Way to Compile Large Project

Reply
Thread Tools

Best Way to Compile Large Project

 
 
David T. Ashley
Guest
Posts: n/a
 
      12-28-2006
I have a large project on a Linux box that may eventually have several
hundred 'C' source files, which need to be compiled and linked into several
executables.

Not all of the executables will use all of the files (i.e. there would be no
linker references to some symbols).

The project will naturally be broken down into several or more
subdirectories.

Questions:

a)What is the best way in general to build? Compile all the .c files into
corresponding .o files, and then link the .o files explicitly?

b)Any thoughts on doing this with "make"?

c)Any thoughts on the limitations of the linker?

Thanks.



 
Reply With Quote
 
 
 
 
Pascal Bourguignon
Guest
Posts: n/a
 
      12-28-2006
"David T. Ashley" <(E-Mail Removed)> writes:

> I have a large project on a Linux box that may eventually have several
> hundred 'C' source files, which need to be compiled and linked into several
> executables.
>
> Not all of the executables will use all of the files (i.e. there would be no
> linker references to some symbols).
>
> The project will naturally be broken down into several or more
> subdirectories.
>
> Questions:
>
> a)What is the best way in general to build? Compile all the .c files into
> corresponding .o files, and then link the .o files explicitly?


Yes. An alternative, if the project is big, with subparts evolving at
different paces, would be to make libraries of subprojects (modules).

Also, it could be faster to build the libraries and link several
programs with a choice of these libraries, rather than linking these
programs from all the object files everytime. (Better benchmark it,
it'd depend on the project).


> b)Any thoughts on doing this with "make"?


Yes. But read this first:

http://members.canb.auug.org.au/~mil...cons-harm.html

ie. use only one Makefile.


> c)Any thoughts on the limitations of the linker?


None. I've got an empty brain. Sorry.


--
__Pascal Bourguignon__ http://www.informatimago.com/

"Specifications are for the weak and timid!"
 
Reply With Quote
 
 
 
 
dcorbit@connx.com
Guest
Posts: n/a
 
      12-28-2006
David T. Ashley wrote:
> I have a large project on a Linux box that may eventually have several
> hundred 'C' source files, which need to be compiled and linked into several
> executables.
>
> Not all of the executables will use all of the files (i.e. there would be no
> linker references to some symbols).
>
> The project will naturally be broken down into several or more
> subdirectories.
>
> Questions:
>
> a)What is the best way in general to build? Compile all the .c files into
> corresponding .o files, and then link the .o files explicitly?
>
> b)Any thoughts on doing this with "make"?
>
> c)Any thoughts on the limitations of the linker?
>
> Thanks.


<OT>
Have you tried Eclipse and CDT?
http://www.eclipse.org/
http://www.eclipse.org/cdt/
</OT>

 
Reply With Quote
 
Barry
Guest
Posts: n/a
 
      12-28-2006

"David T. Ashley" <(E-Mail Removed)> wrote in message
news:nBGkh.37629$(E-Mail Removed). ..
> I have a large project on a Linux box that may eventually have several
> hundred 'C' source files, which need to be compiled and linked into

several
> executables.
>
> Not all of the executables will use all of the files (i.e. there would be

no
> linker references to some symbols).
>
> The project will naturally be broken down into several or more
> subdirectories.
>
> Questions:
>
> a)What is the best way in general to build? Compile all the .c files into
> corresponding .o files, and then link the .o files explicitly?
>
> b)Any thoughts on doing this with "make"?
>
> c)Any thoughts on the limitations of the linker?
>
> Thanks.
>
>
>


Build tools are off topic for clc, but you could start by looking
at make. The last time some of the folks on this board tried to
respond to a questions about "make" several showed they had
noclue Best done by a search and use of your man pages.

<<OT>>
If you have a fully installed development environment you may
take a look at autoconf and automake. But, they come with
caveats with you should look at as well, which may lead you
to better tools.
<</OT>>


 
Reply With Quote
 
Henrik Goldman
Guest
Posts: n/a
 
      12-28-2006
> b)Any thoughts on doing this with "make"?
>

We're in a situation much like your own. More then 100 files, at least 10
applications build from both our "framework" code and application specific
code.

If you consider make then try out makepp instead:
http://makepp.sourceforge.net/

I've used it for like 3 years for now and don't regret it at all!
It's suppose to be a make replacement and it solves several issues that make
has.
E.g. it has an automatic dependency scanner and I've never suffered from
files which were not correctly recompiled.
Also it won't need recursing (in most cases) like traditional make.

Besides you can write extra scripts for it in perl.

The downside is though that it's a bit slower since it's written in perl.
However this is a cheap price to pay. Also the latest build from CVS is
nessecary but not always stable. I've contributed with alot of feedback to
the project so far but usually it's only for the better.

One more thing is that it's very portable. We use it on Windows, Linux,
Macosx, Solaris, AIX and HP-UX and also support several cross compilers
without additional scripts or applications.

At least if you consider make then give this one a try.

-- Henrik


 
Reply With Quote
 
Stefaan A Eeckels
Guest
Posts: n/a
 
      12-28-2006
On Wed, 27 Dec 2006 22:11:31 -0500
"David T. Ashley" <(E-Mail Removed)> wrote:

> I have a large project on a Linux box that may eventually have
> several hundred 'C' source files, which need to be compiled and
> linked into several executables.


That's not a large project

> Not all of the executables will use all of the files (i.e. there
> would be no linker references to some symbols).


Then you should consider using shared objects (.so libraries).

> The project will naturally be broken down into several or more
> subdirectories.


One hopes so. Also consider using a version control system. Subversion
is pretty neat and a doddle to set up.

> Questions:
>
> a)What is the best way in general to build? Compile all the .c files
> into corresponding .o files, and then link the .o files explicitly?


See above. One would normally group the related functions into shared
libraries, and then link the various programs against these libraries.
Just linking everything statically is so twentieth century, dear

>
> b)Any thoughts on doing this with "make"?


Make is the time-honoured way to do this. You need to spend some time
mastering its syntax, but once you know how to use it, make is a very
powerful tool. There are alternatives to make, but they have their own
limitations and idiosyncrasies, in addition to being niche products.

> c)Any thoughts on the limitations of the linker?


Unless you have some specific requirements you did not mention, rest
assured that for a project like yours (building a few executables from
a moderate number of source files) the Unix linkers have no
limitations.

--
Stefaan A Eeckels
--
"We have gone from a world of concentrated knowledge and wisdom to one
of distributed ignorance. And we know and understand less while being
increasingly capable." Prof. Peter Cochrane, formerly of BT Labs
(With thanks to Brian Hamilton Kelly)
 
Reply With Quote
 
toby
Guest
Posts: n/a
 
      12-28-2006

Barry wrote:
> "David T. Ashley" <(E-Mail Removed)> wrote in message
> news:nBGkh.37629$(E-Mail Removed). ..
> > I have a large project on a Linux box that may eventually have several
> > hundred 'C' source files, which need to be compiled and linked into

> several
> > executables.
> >
> > Not all of the executables will use all of the files (i.e. there would be

> no
> > linker references to some symbols).
> >
> > The project will naturally be broken down into several or more
> > subdirectories.
> >
> > Questions:
> >
> > a)What is the best way in general to build? Compile all the .c files into
> > corresponding .o files, and then link the .o files explicitly?
> >
> > b)Any thoughts on doing this with "make"?


Yes.

> >
> > c)Any thoughts on the limitations of the linker?
> >
> > Thanks.
> >
> >
> >

>
> Build tools are off topic for clc, but you could start by looking
> at make. The last time some of the folks on this board tried to
> respond to a questions about "make" several showed they had
> noclue Best done by a search and use of your man pages.


What also tends to be revealed by make *questions* is that the
questioner has not read 'info make'[1], which should a first step to
any serious use of it.

[1] Online here: http://www.gnu.org/software/make/manual/make.html

>
> <<OT>>
> If you have a fully installed development environment you may
> take a look at autoconf and automake. But, they come with
> caveats with you should look at as well, which may lead you
> to better tools.
> <</OT>>


 
Reply With Quote
 
jussij@zeusedit.com
Guest
Posts: n/a
 
      12-28-2006
David T. Ashley wrote:

> b)Any thoughts on doing this with "make"?


IMHO once any project grows to anything over one or two files,
using make is the only way to go.

Also if you take a little bit of time to understand make files:

http://www.zeusedit.com/forum/viewtopic.php?t=300

you'll find make is pretty easy to use.

Jussi Jumppanen
Author: Zeus for Windows
http:\\www.zeusedit.com

 
Reply With Quote
 
Logan Shaw
Guest
Posts: n/a
 
      12-29-2006
toby wrote:
> What also tends to be revealed by make *questions* is that the
> questioner has not read 'info make'[1], which should a first step to
> any serious use of it.


Provided you have a specific reason to use GNU make. If not, then
reading some documentation that isn't GNU-specific might be a better
idea.

- Logan
 
Reply With Quote
 
Logan Shaw
Guest
Posts: n/a
 
      12-29-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Jussi Jumppanen
> Author: Zeus for Windows
> http:\\www.zeusedit.com

^^

I'm sure you meant to give a legal URI there...

- Logan
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
compile errors when converting web site project to web application project John Dalberg ASP .Net 1 03-28-2007 12:54 AM
cant compile on linux system.cant compile on cant compile onlinux system. Nagaraj C++ 1 03-01-2007 11:18 AM
Best way to handle large lists? Chaz Ginger Python 19 10-04-2006 09:15 AM
Best way to store a large number of files? heather.fraser@gmail.com Java 13 10-10-2005 01:11 PM
Best Way To Break Up Large ASP.NET Apps Chris ASP .Net 4 07-15-2004 02:55 PM



Advertisments