本文介绍了如何编译Linux C程序以在另一台Linux机器上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VPS托管我的网站,但未安装gcc软件包. libc.so.6映射到libc-2.12.so,这是我的问题,因为在我的家用计算机上,该库映射到libc-2.15.so

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

我有时需要在VPS上运行一些程序,因此,在编译C源代码时,我使用-static选项将可执行文件包括在内.该程序运行良好,但令我感到困扰的是可执行文件约为800 Kb.如果我不使用-static选项进行编译,则可执行文件约为80 Kb,但在VOS上不起作用.

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.

有人不使用-static选项知道其他任何编译解决方案,从而使可执行文件更小吗?

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

非常感谢您.

推荐答案

构建一个chroot,其中包含与另一台计算机上相同的库和可执行文件,然后在其中执行构建.

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

这篇关于如何编译Linux C程序以在另一台Linux机器上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 07:15