How to compile a program for different target machine than host machine?
At work, we have a project that compiles and runs on Debian Jessie. Typically, we use build servers for compiling, but I would like to move compilation to my own Linux box. I have tried to compile the program on Mint Sarah and Debian Stretch with no luck. I have tried installing Jessie, but the drivers are too out-of-date for my Linux box.
I can compile on Stretch, but won't run on the target machines because the shared library versions don't match. When I match library versions in Sarah and Stretch to the ones in Jessie I get linking errors. So, can I compile a program for Debian Jessie on another Debian variant with newer libraries? I am coming to the conclusion that it is not. I am looking at using a VM, but if I go that route I want something that is light weight and preferably using only the command line. Any suggestions? |
Cross compiling, or is it just another version of Linux, use an older version of gcc possibly?
Install the same version of the target machine in a VM & compile it in there? |
The reason why you have build servers is that they are configured to compile for the exact outcome desired.
Ask the persons who set up the build servers to help you with this. It's not that you haven't given us enough information (you haven't), but it is also that you cannot give us enough information. I feel there are things which you do not fully know about how those build servers are configured. |
> I have tried to compile the program on Mint Sarah and Debian Stretch with no luck.
Some details, please? |
Sorry for the shotgun approach. The following are packages on the build servers. I have installed these on my Debian Stretch (matching versions):
When I try to link the program "foo" together, I get the following errors: Code:
g++ -ggdb -DWITH_OPENSSL -std=c++11 -O3 ../build/obj/Foo.o -L../build/obj/ -L/home/josarlo84/.local/lib -lpthread -lssl -lcrypto -lgsoapssl++ -lmysqlclient -lboost_thread -lboost_system -lpcap -lboost_date_time -lboost_filesystem -lboost_regex -lxerces-c ../build/obj/foo_api.a ../build/obj/shared_api.a -o ../build/Foo |
(You know what Gautama Buddha said: C++ leads to suffering)
Are you sure you cannot install these components from official packages instead of manually copying something into nonstandard places? |
All packages are installed using aptitude with Jessie repository except for boost libraries. I manually downloaded and compiled boost because when I tried to install from apt-get Jessie and Stretch versions clashed.
|
The other items you may need are:
|
How about installing a newer version of boast? Normally a newer version of a library should provide the functionality of an older version.
|
Quote:
Quote:
Quote:
After downgrading g++ from 4.6 to 4.4, to match the build servers, I get the linking errors described above. |
Quote:
|
Quote:
Quote:
HOWEVER, as you're saying, they won't properly run on the target. Now ... this target is either matching the CPU from where you're compiling, or it is entirely different. Once again, we don't know if this is cross compilation, or something else. Just because you link something successfully only means that you satisfied the library requirements on the build machine you're using. However if those linked-to libraries are not matching the ones on the target environment, then they won't work. |
Forget distribution, you've already described this.
What are the hardware specifications for your build machine? The one you are using. What are the hardware specifications for your target? |
@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.)
|
Quote:
Quote:
|
All times are GMT -5. The time now is 04:12 AM. |