Compile shared library into a program?

前端 未结 2 1717
余生分开走
余生分开走 2021-01-28 12:35

I wrote a program, that uses a shared library installed on my system. This library is seldom installed on other systems. How do I compile my program so that the library doesn\'t

相关标签:
2条回答
  • 2021-01-28 13:09

    Though the OP had solved his problem by answering a different question, there are (at least) two ways to wedge a shared library into your binary in case

    • there is no source code available
    • there is no compiler (or build-chain) available
    • static link does not work or it's not obvious how do it
    • to preserve memory layout - static link will change it and may "wake-up" hidden bugs
    • for "permanent link" LD_PRELOAD library into executable

    The first is statifier (open source but limited to x86 and x86_64 and only object code)

    The second that I know of is magic ermine (by the same developer). It is closed source, but the developer is friendly to opensource projects and ermine has the advantage of supporting more platforms as well as the ability to include all necessary data files within its virtual file system.

    http://statifier.sourceforge.net/ and http://www.magicermine.com/

    0 讨论(0)
  • 2021-01-28 13:11

    Compile it as a static library and link that into the executable.

    0 讨论(0)
提交回复
热议问题