The output of the configure script shows:
configure:2691: gcc -Wl,-static conftest.c >&5
ld: 0706-012 The -t flag is not recognized.
ld: 0706-012 The -a flag is not recognized.
ld: 0706-012 The -t flag is not recognized.
ld: 0706-027 The -i flag is ignored.
ld: 0706-012 The -c flag is not recognized.
collect2: ld returned 255 exit status
This indicates that the -Wl
option is successfully passing the option to ld, but ld does not recognize the option. As you're using AIX ld, it requires using -dn
along with -bsvr4
with the link line, so, for example the flags option should read -Wl,-bsvr4 -Wl,-dn
.
There is a note at the end of the man page for ld
on AIX which states that:
The application can also have to be linked again whenever an updated release of the operating system is installed. Any application that is statically linked is not binary portable from any fix or release level to any other fix or release level.
Depending on the complexity of the final link line for proftpd, you can use the options -bstatic
and -bdynamic
to prompt the loading of static libraries for specific items; so in my case my final link line looked like:
gcc -o proftpd <lots of .o files> -L/home/user/Development/experiments/proftpd-1.3.4d/lib -lsupp -lcrypt -ldl -L/home/user/Development/experiments/proftpd-1.3.4d/lib/libcap -lcap -lpam
Now in this case, it means that it depends on libcrypt, which isn't a default shipped library, so I rejig the link line so that it has the -lcrypt
wrapped:
-Wl,-bstatic -lcrypt -Wl,-bdynamic
and now it links with the static version of the crypt library, and no longer mentions it as part of the run-time link dependencies.
As an addenda to this, you should only static link the libraries that aren't shipped by default on the OS in question, and I note that proftpd supports dynamically loading modules, which means that you should only statically link the required modules.
In general, though, if you're building to deploy on another system, I would advise creating static-only copies of the dependent libraries that you're using and explicitly pass them into the configure options. This keeps the build environment clean from the run-time environment.