Should I compile a library from source?

主宰稳场 提交于 2019-12-07 14:47:28

问题


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.

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?


回答1:


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.

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.



来源:https://stackoverflow.com/questions/20579124/should-i-compile-a-library-from-source

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