How to statically-link a complex program

前端 未结 4 865
傲寒
傲寒 2020-12-23 23:50

In Linux, downloaded a program source and want it to be statically linked. Have a huge Makefile there, I

./configure
make

to compile. preh

相关标签:
4条回答
  • 2020-12-24 00:34

    Yeah, you need to edit the make file and add the -static parameter to gcc during the link.

    0 讨论(0)
  • 2020-12-24 00:38

    If you cannot compile a static binary, I've had good results using Statifier.

    0 讨论(0)
  • 2020-12-24 00:45

    Most autoconf generated configure script will allow you to make a static build:

     ./configure --enable-static
     make
    

    If that doesn't work, you may be able to pass linker flags in via LDFLAGS, like this:

     ./configure LDFLAGS=-static
    
    0 讨论(0)
  • 2020-12-24 00:48

    I assume it's using gcc to compile a series of c programs, although you will have to look in the Makefile to find out.

    If so, you can adjust the gcc lines in the makefile to do static linking, although depending upon the structure of the program, this may be a complex change. Take a look at man gcc to see how this is done.

    I'd be interested to know why you are statically linking. Have you considered using prelinking instead?

    You should be aware that there may be licence problems to doing this if all components are not GPL.

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