简体   繁体   中英

Linux lib / include organization for cross-compiled libraries?

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/ /usr/local/share/google/lib (and include) / usr / local / share / google / lib(包括)
  • /usr/local/ /lib (and include) / lib(包括)

    Any pointers appreciated!

  • 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.

    The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM