s g
s g

Reputation: 5637

Should I compile a library from source?

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?

Upvotes: 4

Views: 985

Answers (1)

herohuyongtao
herohuyongtao

Reputation: 50667

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.

Upvotes: 2

Related Questions