LINUX GAZETTE
...making Linux just a little more fun!
(?) The Answer Gang (!)
By Jim Dennis, Ben Okopnik, Dan Wilder, Breen, Chris, and... (meet the Gang) ... the Editors of Linux Gazette... and You!


We have guidelines for asking and answering questions. Linux questions only, please.
We make no guarantees about answers, but you can be anonymous on request.
See also: The Answer Gang's Knowledge Base and the LG Search Engine



(?) Compile on one, run on another machine

From Ferenc-Jan

Answered By: Thomas Adam

Hi there!

I've got a question that may be of interest to the linuxgazette community. Where does one go to find out more about cross compiling? (I'm not even sure cross compiling is the correct term for this.)

(!) [Thomas] Cross-compiling refers to compiling applications on a computer that is not intended for the same computer because often the target computer has a different architecture.

(?) The case is this: I often want to compile stuff on one machine but run it on another. My permanently-in-disrepair, bleedingly fast & incredibly messy test system is the machine of choice for compiling all kinds of linux stuff. The barely alive, old laptop or the lean & mean firewall box aren't - besides, I don't want a full blown gcc environment on those. But I run into problems most of the time.

Approach A: compile it as per instructions. Then I have to go and find all the nitty bitty parts of the package, that are now residing everywhere on the test system's drive. This often fails because missing parts don't always generate comprehensible error messages.

(!) [Thomas] This is not an approach, this is what usually happens when you compile a program.

(?) Approach B: try to install it to a different directory, i.e. /tmp/ and then move it to the other machine. This often founders on hard coded file location, i.e. when /tmp/lib/something is actually at /usr/local/lib/something (like it should be.)

(!) [Thomas] This is dependant upon how ldconfig registers where the libraries are (possibly by way of $LD_LIBRARY_PATH).

(?) I don't consider myself a beginner, but who does. I don't seem to be able to google the answer to this problem, but surely I'm not the only one running into this?

Any hints would be much appreciated, but I understand this must be relevant to linuxzgazette before you can spend your time on this.

(!) [Thomas] I'm not quite sure what it is you're asking. If it is "how can I compile applications such that I can minimize the number of (likely) errors", then the answer is to compile it statically so that the application doesn't have to go using any external libraries. The only disadvantage with this is that the resultant binary is often very large.
Dynamic libraries are the most popular -- much smaller, but it does mean that it is up to the user to ensure that these libraries are installed. 'ldd' goes a long way to checking and ensuring that is the case. But at compilation time, the user is often told what libraries (if any) are needed.
The querent then reported back that all was right with the world and that he found what he was after. I suppose we call all learn a lesson here in that being precise is important when asking questions, otherwise your question may never get the correct answer! -- Thomas Adam

(?) Anyway, another helpful soul came up with the answer on Usenet:

make prefix=/tmp/foo install.

That is exactly what I'm looking for. With this I can drop everything in an empty dir, gzip it, move it to another machine and unpack it & run it. Never thought it would be this simple, I tried this with configure --prefix=/tmp/foo, but that's where /tmp/foo gets into the compiled files.


This page edited and maintained by the Editors of Linux Gazette
Copyright © its authors, 2004
Published in issue 101 of Linux Gazette April 2004
HTML script maintained by Heather Stern of Starshine Technical Services, https://www.starshine.org/


[ Table Of Contents ][ Answer Guy Current Index ] greetings   Meet the Gang   1   2   3   4   5   6   7 [ Index of Past Answers ]