Prof. A Olowofoyeku (The African Chief) wrote:
I have downloaded Frank's cgiprogs package, for the purpose of building a cgi program for an adsl router (running MontaVista Linux on a mipsfple processor). First, hats off to Frank. The program compiled and runs fine on the router. The problem is the size of the compiled program (320kb when statically linked with libgpc.a, and 250kb when linked to libgpc.so, which itself is 320kb). This is a significant amount of space for a single program to take on a router.
My question (and probably only Frank can answer this) is, how can one reduce the size of this program? The program uses the gpc and cgi units only. From the GPC unit it calls "Execute" and "GetTempDirectory", and from the cgi unit it calls: GetVar IsCGI CGIInitVars
The basic problem is that gpc doesn't support smart-linking, which implies that unused routines end-up in the executable, runtime library routines included. So, the easiest way to reduce the size of the executable is to create a special version of libgpc, manually removing anything unused.
What also might help (to a certain extent) is to let the linker strip - all debug info - all symbol info The details may vary per platform (pass something like -Wl,-s).
Regards,
Adriaan van Os