我应该从源代码编译库吗? [英] Should I compile a library from source?

查看:72
本文介绍了我应该从源代码编译库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个将在基于debian的定制构建的linux系统上运行的应用程序.我们有一个工具链,以便我们可以针对目标系统交叉编译应用程序,这样,我们就不必依赖要进行编译的主机操作系统(与目标操作系统相对).

I'm working on an application that will run on a custom-built, debian-based linux system. We have a toolchain so that we can cross-compile the application for the target system, that way we don't have to depend on the host OS (as opposed to target OS) on which we're doing the compilation.

我不确定,但是我们是否应该从源代码交叉编译第三方库,还是应该只使用预定义的库和头文件.例如,基于此页面,libSDL1.2似乎与发行版无关( http://www. libsdl.org/download-1.2.php ),所以我们似乎不需要从源代码进行编译..但是其他一些库对于BSD,Ubuntu,Redhat等具有不同的风格,这使我认为我们需要使用我们的工具链进行编译.

I'm not sure, however if we should be cross-compiling the 3rd party libraries from source or whether we should just use the pre-canned libraries and header files. For example, libSDL1.2 seems to be distro-agnostic based on this page (http://www.libsdl.org/download-1.2.php) so it would seem that we don't need to compile it from source.. but some other libraries have different flavors for BSD, Ubuntu, Redhat, etc. which makes me think that we need to compile those with our toolchain.

我什么时候应该从源代码编译库?有什么要考虑的?

When should I compile a library from source? What things are there to consider?

推荐答案

从源代码编译/构建第三方库始终是一件好事.尽管您提到的某些库,例如OpenCVlibSDL可以直接使用而无需编译,但仍可以通过根据您的首选选项重新构建它们而不使用它们的默认选项而受益匪浅.例如,通过重新构建OpenCV,可以添加适合您的PC的CUDA功能以加快速度.

It's always a good thing to compile/build a 3rd-party library from source. Although some libraries like OpenCV or libSDL you mentioned can be directly used without compiling, you can still benefit a lot by re-build them according to your preferred options instead of using their default options. For example, by re-build OpenCV, you can add CUDA feature that is suitable for your PC to speed it up.

要编译/构建第三方,可以使用cmake.对于大多数第三方库,它们都包含一个名为CMakeLists.txt的文件供您执行.

To compile/build a 3rd-party, you can use cmake. For most 3rd-party libraries, they contain a file called CMakeLists.txt for you to do that.

这篇关于我应该从源代码编译库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆