如何在编译时静态链接libevent和gcc?
我在我的项目中使用了 event.h,但它必须运行的服务器不支持它。而且我也无法安装它。有没有一种方法可以以最少的修改运行我的项目。
它必须编译为静态链接,但我该怎么做呢?
I have used event.h in on of my project but the server it has to run on does not support it. Moreover I can not install it also. Is there a way I can run my project with minimum modifications.
It has to be compiled statically linked in but how do I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
运行它的服务器不支持它是什么意思?如果未安装共享库,您可以使用静态链接的库来构建项目。
或者,编译 libevent 的共享库并将其包含在您的应用程序中。我已经成功地使用 ELF 二进制文件和共享库中的 RUNPATH 标头将应用程序目录放在动态库加载搜索路径的开头。
https://github.com/wavetossed/pybuild 是 Python 2.7 的构建脚本示例。 2 和几十个二进制模块,其中包括使用 libevent。使用 RUNPATH 构建单个库要简单得多。
What do you mean the server it has to run on does not support it? If a shared library is not installed, you can just build your project with the library statically linked in.
Alternatively, compile a shared library of libevent and include it with your application. I have had success using the RUNPATH headers in ELF binatries and shared libraries to put an application directory at the beginning of the dynamic library loading search path.
https://github.com/wavetossed/pybuild is an example of a build script for Python 2.7.2 and a couple dozen binary modules, which includes using libevent. Building just a single library using RUNPATH is much simpler.