How to compile a program for different target machine than host machine?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
So it works properly when you build within Debian Jesse?
And you are trying to run Stretch or Mint on your build machine and similarly get it to work?
Use a VM on your system to run Debian Jesse to do your builds and then have your build machine be whatever it needs to be.
This is similar to what NevemTeve is saying.
This is also very typical of a cross compilation situation, where you install tools, get them correct, and then never change them. You seem to be changing the tools, and you shouldn't because the target isn't changing. I do realize it is not technically "cross compilation", however, it is some form of tools revision issue, which is coupled with the libraries and files provided specifically by Debian Jesse.
@OP: I cannot follow you. If you want to use the program on computer X, then compile it from source on computer X. That's how things work in Unix (unlike Windows, for example.)
My motivation is to utilize resources. I have a new machine with quite a bit of power. I'd like to offload our build server because there are 8 people using it. A compile takes 40 minutes for one user using an optimized make configuration. When multiple users use the server, build time increases. I may be ignorant, but I figured this could be done because the hardware architecture is the same and I am using a variant of Debian.
So it works properly when you build within Debian Jesse?
And you are trying to run Stretch or Mint on your build machine and similarly get it to work?
Use a VM on your system to run Debian Jesse to do your builds and then have your build machine be whatever it needs to be.
This is similar to what NevemTeve is saying.
This is also very typical of a cross compilation situation, where you install tools, get them correct, and then never change them. You seem to be changing the tools, and you shouldn't because the target isn't changing. I do realize it is not technically "cross compilation", however, it is some form of tools revision issue, which is coupled with the libraries and files provided specifically by Debian Jesse.
This is what I feared . I have wanted to avoid using a VM because I don't want to reserve system resources for functionality that I don't need. Do you know of a lightweight VM that will allow me to do a barebones configuration just for doing a build? I would like to make it as transparent as possible.
You seem to be conflicted about the reasons for trying to configure your own build machine, and should think that through more clearly before trying to put the build system together.
Quote:
Originally Posted by josarlo84
My motivation is to utilize resources. I have a new machine with quite a bit of power. I'd like to offload our build server because there are 8 people using it.
Quote:
Originally Posted by josarlo84
I have wanted to avoid using a VM because I don't want to reserve system resources for functionality that I don't need.
If you have anything that can be described as a new machine with quite a bit of power, then setting up a VM with a dedicated build environmet should be no drain on resources and almost trivial compared to the required effort and problems resulting from installing non-standard library versions on the host.
Clearly you do need those resources to build for another platform - no need to make it more difficult than it should be. Use the resources - that is what they are for!
Quote:
Originally Posted by NevemTeve
@OP: I cannot follow you. If you want to use the program on computer X, then compile it from source on computer X. That's how things work in Unix (unlike Windows, for example.)
This is a very good point - a primary feature (characteristic) of the *nix environment, and Free software generally, is the ability to build on the target machine. Make full use of that!
And as has been said several times, use a VM - it solves almost all the problems easily.
Quote:
Originally Posted by rtmistler
Use a VM on your system to run Debian Jesse to do your builds and then have your build machine be whatever it needs to be.
This is similar to what NevemTeve is saying.
This is also very typical of a cross compilation situation, where you install tools, get them correct, and then never change them.
Quote:
Originally Posted by josarlo84
Do you know of a lightweight VM that will allow me to do a barebones configuration just for doing a build? I would like to make it as transparent as possible.
Can you define "light weight", or do you have any specific requirements? Just install Virtual Box (or another VM), install the build target and give it a try! Don't complicate the process by trying to solve non-existent problems! If you hit some resource limit or problem, then you will have a problem with parameters to be solved!
Can you define "light weight", or do you have any specific requirements? Just install Virtual Box (or another VM), install the build target and give it a try! Don't complicate the process by trying to solve non-existent problems! If you hit some resource limit or problem, then you will have a problem with parameters to be solved!
When I say light weight, I mean something that runs with minimal drain on system resources. Virtual Box is a great solution, however, it requires dedicated x number of processors and y GB of ram. Compiling code requires to startup the VM, wait for boot, and then execute the code. I would rather not develop in the virtual environment, so any compilation bugs would have to be resolved on the host machine, and then compilation restarted.
I found my solution: dchroot. I installed my target OS on a separate partition. On host, I mount the partition and bind mount other necessary locations (i.e. /proc, /dev, and src directories). I then execute dchroot, and run the compile. There is no need to run a VM with dedicated RAM and processors. It essentially created a development sandbox with the correct libraries installed in the right location. I can integrate this with emacs, and it doesn't feel like I am doing anything special. Compilation is fast and I don't have to utilize resources on the build machine.
I am a newbie, so any viewpoints that could make this solution even better are welcomed!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.