Ad

Linux Lib / Include Organization For Cross-compiled Libraries?

- 1 answer

We are cross-compiling an application for an embedded Linux target under desktop Linux. For testing and other purposes we are using statically linked libraries with our application. The testing library we are using is CMockery.

My question is: Where should the static libraries and include files for CMockery live, given that we are cross-compiling?

If we weren't cross-compiling, things should go in /usr/local/lib.

Some suggestions from our team have been:

  • /opt/google/lib and /opt/google/include
  • /opt/embeddedLinuxDistro/usr/local/share/google/lib (and include)
  • /usr/local/arch/lib (and include)

    Any pointers appreciated!

  • Ad

    Answer

    Note: After writing this answer, my summary would be:

    Keep anything that is non-standard to the Linux distro you're using separate. In fact keep files for different projects separate even if they share libraries. This will make it much easier to move your files to another machine, to setup multiple complete builds for testing, and most importantly to be able to recreate the build starting from scratch.


    The decision is really subjective.

    • Do you just need one copy of the library for all users?
    • Does it rarely change?
    • If your build machine caught fire and you had no backups of that machine, how quickly and easily could you re-build your environment of libraries and cross-compilers?

    I ask these questions, because if the library changes often or different users may need different versions, you're better off having it be portable. That is, you can specify in your build where to find the files.

    Of your team's suggestions, I would lean towards a path that contains a reference to your project. This will make it easier a year from now (when someone asks you to setup another build machine) to reproduce everything.

    Lastly, I wouldn't worry about trying to adhere to "standard" library locations because you're not creating and managing a Linux distribution. Furthermore, most people don't really know anything more than "/usr/lib" and /usr/local/lib" and even the people that know those do not know the difference.

    Do what's best for your project no matter what that may be.

    Ad
    source: stackoverflow.com
    Ad