How to compile Linux C program to run on another Linux machine?

左心房为你撑大大i 提交于 2019-12-23 03:15:35

问题


I am using a VPS to host my website, but the gcc package is not installed. The libc.so.6 is mapped to libc-2.12.so and this is my problem, because on my home computer the library is mapped to libc-2.15.so

From time to time, I need to run some programs on VPS, so when I compile the C sources I use the -static option to include in the executable file everything is needed. The program works fine, but it bothers me that executable is about 800 Kb. If I compile without using -static option, executable is about 80 Kb, but it doesn't work on VOS.

Does anybody know any other solution to compile without using -static option, such that the executable be smaller ?

Thank you very much.


回答1:


Build a chroot containing the same libraries and executables as on the other machine, and perform the build in there.



来源:https://stackoverflow.com/questions/17398943/how-to-compile-linux-c-program-to-run-on-another-linux-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!