LinuxQuestions.org
Review your favorite Linux distribution.
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 03-07-2006, 09:12 AM   #1
jaristr
Member
 
Registered: Aug 2005
Distribution: Debian and slackware based
Posts: 119

Rep: Reputation: 15
Is there incremental linker for linux?


Hello,
I have been using GCC to compile in linux but compiling large projects takes time because as far as I know the linking isnt incremental, is this correct?
Is there any way to build faster in linux?

Thank you.

Jari.
 
Old 03-07-2006, 11:51 AM   #2
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 42
ld does support incremental linking, but I wonder if that's actually the question you mean to ask. Are you using a Makefile? If not, you probably should be.

The link step usually doesn't take very long. If you're sure that it's the *link* that's taking a long time and not the compile, then ignore this post : )
 
Old 03-07-2006, 11:54 AM   #3
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 55
Make should handle incremental build . For incremental link there is an option in gcc but I have no clue how it works.
To speedup compiles, try
ccache
and
distcc if you have a cluster of machines
 
Old 03-07-2006, 02:09 PM   #4
jaristr
Member
 
Registered: Aug 2005
Distribution: Debian and slackware based
Posts: 119

Original Poster
Rep: Reputation: 15
Sorry, you are right, I was supposed to say that linking (not compiling) takes time with larger projects.
 
Old 03-07-2006, 03:03 PM   #5
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 42
Ok, according to the ld man page you use -i, and it seems to work about as one would expect. Here I have 5 .c files: a.c, b.c, c.c, d.c, and main.c. I compile them all into *.o object files, then incrementally link a.o and b.o into ab.o, and I link c.o and d.o into cd.o. Finally, I link ab.o, cd.o, and main.o into a finished executable named "thing":
Code:
15:59 aluser@alf:~/test/c/incremental$ cat Makefile
thing: ab.o cd.o main.o
        $(CC) -o $@ $^
ab.o: a.o b.o
cd.o: c.o d.o
ab.o cd.o:
        $(LD) -i -o $@ $^
16:00 aluser@alf:~/test/c/incremental$ ls
Makefile  a.c  b.c  c.c  d.c  main.c
16:02 aluser@alf:~/test/c/incremental$ make
cc    -c -o a.o a.c
cc    -c -o b.o b.c
ld -i -o ab.o a.o b.o
cc    -c -o c.o c.c
cc    -c -o d.o d.c
ld -i -o cd.o c.o d.o
cc    -c -o main.o main.c
cc -o thing ab.o cd.o main.o
16:02 aluser@alf:~/test/c/incremental$ ./thing
Hello, world
 
Old 03-09-2006, 02:28 PM   #6
jaristr
Member
 
Registered: Aug 2005
Distribution: Debian and slackware based
Posts: 119

Original Poster
Rep: Reputation: 15
aluser, thank you!
That looks like a great solution, I wonder how hard it's going to be to get that working in KDevelop or in anjuta.
 
Old 03-11-2006, 01:09 PM   #7
jaristr
Member
 
Registered: Aug 2005
Distribution: Debian and slackware based
Posts: 119

Original Poster
Rep: Reputation: 15
I have been trying to figure out how to compile C++ files but it looks like that while I can create the object (.o) files with g++ (using -c option) I cannot link them with ld.

So is ld only for C linking?

Thank you.

Jari.
 
Old 03-11-2006, 01:18 PM   #8
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 42
Quote:
So is ld only for C linking?
Hm my guess is that it needs extra options to do c++.. Have you tried using g++ with -Wl,-i ?
 
Old 03-11-2006, 02:02 PM   #9
jaristr
Member
 
Registered: Aug 2005
Distribution: Debian and slackware based
Posts: 119

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by aluser
Hm my guess is that it needs extra options to do c++.. Have you tried using g++ with -Wl,-i ?
You are right the -i was what was needed. So I got it working now, just strange that the --help didnt mention it... and man page merely said it could be used.

Well anyway, thanks for the help, again!
 
  


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
incremental backup .... redrobin77 Linux - Software 1 01-31-2006 05:29 AM
Linker options in portind from solaris to linux for mapfile support phani@tcs Linux - General 2 10-25-2005 11:49 PM
Linux dynamic linker thedevilsjester Programming 4 09-20-2005 07:11 PM
incremental backup reaky Linux - Software 3 03-10-2004 03:02 PM
Incremental install funtoos Linux - Software 14 08-03-2003 05:30 AM

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

All times are GMT -5. The time now is 11:19 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration