0

I have a uclibc toolchain that works. I can compile a simple hello.c program statically (arm-linux-gcc hello.c -o hello -static -s) but source packages are automatically compiled dynamically. How can I change the default to static?

jocala
  • 31
  • 2
  • 6

1 Answers1

0

You have to edit the makefile of the source packet you are compiling (extra LDFLAG -static, just as you did for the hello.c file). Most of the time source packets are delivered with autoconf. In that case you can probably pass the --enable-static-link flag to configure. See configure --help for the set of possible arguments.

Other note: be careful when cross compiling packages which need other libraries. You do not want to link in your host machine libraries statically.

Michel
  • 2,523
  • 2
  • 17
  • 14
  • I still get a dynamically linked prog when editing Makefile. Compiling lighttpd with CFLAGS = -g -O2 -Wall -W -Wshadow -pedantic -std=gnu99 -static results in: file src/lighttpd: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped. Compiling the joe editor gives the same results. – jocala Oct 10 '11 at 17:53
  • My bad, you should look for LDFLAGS, which contain the flags for linking and add -static to that. – Michel Oct 10 '11 at 19:23
  • Thanks. It's still not working, so I'm investigating my toolchain for problems. And I thiught this would be simple :( – jocala Oct 11 '11 at 00:34
  • I tried to compile lighttpd for you (version 1.4.28) and discovered that you have set CFLAGS before configure. So CFLAGS='--static' ./configure. It gives ELF 32-bit LSB executable, ..., statically linked, not stripped. Sorry about the confusion with LDFLAGS and CFLAGS, it really depends on the package you are trying to compile ;-) – Michel Oct 11 '11 at 06:48