Question

I'd like to compile proftpd on AIX to make it deployable on other server without having to reinstall all gnu lib library on each server.
I already manage to compile it dynamicaly, but I can't manage to get it compile with the option

 LDFLAG="-Wl,-static"  

like advise in the official proftpd documentation.
here the config.log error I get

This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by configure, which was
generated by GNU Autoconf 2.61.  Invocation command line was

  $ ./configure LDFLAGS=-Wl,-static --with-modules=mod_tls:mod_sql:mod_sql_mysql:mod_sql_passwd:mod_sftp:mod_sftp_sql --without-getopt --enable-openssl --with-includes=/opt/freeware/include:/opt/freeware/include/mysql/mysql/:/home/poney2/src_proftpd/libmath_header/ --with-libraries=/opt/freeware/lib:/opt/freeware/lib/mysql/mysql/:/home/poney2/src_proftpd/libmath_lib --prefix=/home/poney/proftpd_bin --exec-prefix=/home/poney/proftpd_bin/proftpd

## --------- ##
## Platform. ##
## --------- ##

hostname = serverName
uname -m = 00C876004C00
uname -r = 1
uname -s = AIX
uname -v = 6

/usr/bin/uname -p = powerpc
/bin/uname -X     = unknown

/bin/arch              = unknown
/usr/bin/arch -k       = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo      = unknown
/bin/machine           = unknown
/usr/bin/oslevel       = 6.1.0.0
/bin/universe          = unknown

PATH: /usr/bin
PATH: /etc
PATH: /usr/sbin
PATH: /usr/ucb
PATH: /home/poney/bin
PATH: /usr/bin/X11
PATH: /sbin
PATH: .


## ----------- ##
## Core tests. ##
## ----------- ##

configure:2122: checking build system type
configure:2140: result: powerpc-ibm-aix6.1.0.0
configure:2162: checking host system type
configure:2177: result: powerpc-ibm-aix6.1.0.0
configure:2199: checking target system type
configure:2214: result: powerpc-ibm-aix6.1.0.0
configure:2346: checking for gcc
configure:2362: found /usr/bin/gcc
configure:2373: result: gcc
configure:2611: checking for C compiler version
configure:2618: gcc --version >&5
gcc (GCC) 4.4.6
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:2621: $? = 0
configure:2628: gcc -v >&5
Using built-in specs.
Target: powerpc-ibm-aix6.1.0.0
Configured with: ../gcc-4.4.6/configure --with-as=/usr/bin/as --with-ld=/usr/bin/ld --enable-languages=c,c++,fortran --prefix=/opt/freeware --enable-threads --enable-version-specific-runtime-libs --disable-nls --enable-decimal-float=dpd --host=powerpc-ibm-aix6.1.0.0
Thread model: aix
gcc version 4.4.6 (GCC)
configure:2631: $? = 0
configure:2638: gcc -V >&5
gcc: '-V' option must have argument
configure:2641: $? = 1
configure:2664: checking for C compiler default output file name
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
configure:2694: $? = 1
configure:2732: result:
configure: failed program was:
| /* confdefs.h.  */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PR_BUILD_OPTS " 'LDFLAGS=-Wl,-static' '--with-modules=mod_tls:mod_sql:mod_sql_mysql:mod_sql_passwd:mod_sftp:mod_sftp_sql' '--without-getopt' '--enable-openssl' '--with-includes=/opt/freeware/include:/opt/freeware/include/mysql/mysql/:/home/poney2/src_proftpd/libmath_header/' '--with-libraries=/opt/freeware/lib:/opt/freeware/lib/mysql/mysql/:/home/poney2/src_proftpd/libmath_lib' '--prefix=/home/poney/proftpd_bin' '--exec-prefix=/home/poney/proftpd_bin/proftpd'"
| #define PR_PLATFORM "AIX6 (AIX6_1_0_0)"
| /* end confdefs.h.  */
|
| int
| main ()
| {
|
|   ;
|   return 0;
| }
configure:2738: error: C compiler cannot create executables
See `config.log' for more details.

## ---------------- ##
## Cache variables. ##
## ---------------- ##

ac_cv_build=powerpc-ibm-aix6.1.0.0
ac_cv_env_CC_set=''
ac_cv_env_CC_value=''
ac_cv_env_CFLAGS_set=''
ac_cv_env_CFLAGS_value=''
ac_cv_env_CPPFLAGS_set=''
ac_cv_env_CPPFLAGS_value=''
ac_cv_env_CPP_set=''
ac_cv_env_CPP_value=''
ac_cv_env_LDFLAGS_set=set
ac_cv_env_LDFLAGS_value=-Wl,-static
ac_cv_env_LIBS_set=''
ac_cv_env_LIBS_value=''
ac_cv_env_build_alias_set=''
ac_cv_env_build_alias_value=''
ac_cv_env_host_alias_set=''
ac_cv_env_host_alias_value=''
ac_cv_env_target_alias_set=''
ac_cv_env_target_alias_value=''
ac_cv_host=powerpc-ibm-aix6.1.0.0
ac_cv_prog_ac_ct_CC=gcc
ac_cv_target=powerpc-ibm-aix6.1.0.0

## ----------------- ##
## Output variables. ##
## ----------------- ##

ADDL_CPPFLAGS=''
ADDL_DIRS=''
ALLOCA=''
AR=''
ARGZ_H=''
BINDIR=''
BUILD_SHARED_MODULE_OBJS=''
BUILD_STATIC_MODULE_ARCHIVES=''
BUILD_STATIC_MODULE_OBJS=''
CC='gcc'
CFLAGS=''
CONFIG_SHELL='/bin/sh'
CPP=''
CPPFLAGS=''
CURSES_LIBS=''
DATADIR=''
DEFS=''
DSYMUTIL=''
DUMPBIN=''
ECHO_C='ECHO_N=''
ECHO_T=''
EGREP=''
ENABLE_NLS=''
ENABLE_TESTS=''
EXEEXT=''
FGREP=''
GLUE_MODULE_OBJS=''
GREP=''
INCLTDL=''
INCLUDEDIR=''
INCLUDES=''
INSTALL_DATA=''
INSTALL_DEPS=''
INSTALL_PROGRAM=''
INSTALL_SCRIPT=''
INSTALL_STRIP=''
LD=''
LDFLAGS='-Wl,-static'
LIBADD_DL=''
LIBADD_DLD_LINK=''
LIBADD_DLOPEN=''
LIBADD_SHL_LOAD=''
LIBDIRS=''
LIBEXECDIR=''
LIBLTDL=''
LIBOBJS=''
LIBRARIES=''
LIBS=''
LIBTOOL=''
LIBTOOL_DEPS=''
LIB_DEPS=''
LIB_OBJS=''
LIPO=''
LN_S=''
LOCALSTATEDIR=''
LTDLDEPS=''
LTDLINCL=''
LTDLOPEN=''
LTLIBOBJS=''
LT_CONFIG_H=''
LT_DLLOADERS=''
LT_DLPREOPEN=''
MAIN_LDFLAGS=''
MAIN_LIBS=''
MODULE_DEPS=''
MODULE_LDFLAGS=''
NM=''
NMEDIT=''
OBJDUMP=''
OBJEXT=''
OSREL='-DAIX6_1_0_0'
OSTYPE='-DAIX6'
OTOOL64=''
OTOOL=''
PACKAGE_BUGREPORT=''
PACKAGE_NAME=''
PACKAGE_STRING=''
PACKAGE_TARNAME=''
PACKAGE_VERSION=''
PATH_SEPARATOR=':'
PREFIX=''
RANLIB=''
SBINDIR=''
SED=''
SET_MAKE=''
SHARED_MODULE_DIRS=''
SHARED_MODULE_LIBS=''
SHARED_MODULE_OBJS=''
SHELL='/bin/sh'
STATIC_MODULE_DIRS=''
STATIC_MODULE_OBJS=''
STRIP=''
SYSCONFDIR=''
UTILS_LIBS=''
VERSION=''
ac_ct_CC='gcc'
ac_ct_DUMPBIN=''
bindir='${exec_prefix}/bin'
build='powerpc-ibm-aix6.1.0.0'
build_alias=''
build_cpu='powerpc'
build_os='aix6.1.0.0'
build_vendor='ibm'
datadir='${datarootdir}'
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE}'
dvidir='${docdir}'
exec_prefix='/home/poney/proftpd_bin/proftpd'
host='powerpc-ibm-aix6.1.0.0'
host_alias=''
host_cpu='powerpc'
host_os='aix6.1.0.0'
host_vendor='ibm'
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
install_group=''
install_user=''
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
lt_ECHO='print -r'
ltdl_LIBOBJS=''
ltdl_LTLIBOBJS=''
mandir='${datarootdir}/man'
oldincludedir='/usr/include'
pdfdir='${docdir}'
pkgconfigdir=''
prefix='/home/poney/proftpd_bin'
program_transform_name='s,x,x,'
psdir='${docdir}'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
subdirs=''
sys_symbol_underscore=''
sysconfdir='${prefix}/etc'
target='powerpc-ibm-aix6.1.0.0'
target_alias=''
target_cpu='powerpc'
target_os='aix6.1.0.0'
target_vendor='ibm'

## ----------- ##
## confdefs.h. ##
## ----------- ##

#define PACKAGE_NAME ""
#define PACKAGE_TARNAME ""
#define PACKAGE_VERSION ""
#define PACKAGE_STRING ""
#define PACKAGE_BUGREPORT ""
#define PR_BUILD_OPTS " 'LDFLAGS=-Wl,-static' '--with-modules=mod_tls:mod_sql:mod_sql_mysql:mod_sql_passwd:mod_sftp:mod_sftp_sql' '--without-getopt' '--enable-openssl' '--with-includes=/opt/freeware/include:/opt/freeware/include/mysql/mysql/:/home/poney2/src_proftpd/libmath_header/' '--with-libraries=/opt/freeware/lib:/opt/freeware/lib/mysql/mysql/:/home/poney2/src_proftpd/libmath_lib' '--prefix=/home/poney/proftpd_bin' '--exec-prefix=/home/poney/proftpd_bin/proftpd'"
#define PR_PLATFORM "AIX6 (AIX6_1_0_0)"

PS: I already try -Bstatic -all-static and -static flags but they are ignored.


Possible answer

Part of solution for me is modyfing the libpath to add a folder to this where I will put all the lib to pack it as a tar file and deploy the proftpd installation folder with the lib inside, it's not clean but it does work:

LDFLAGS="-Wl,-blibpath:/a/new/lib/path"

I do not validate my answer as it's not the real answer but that could help some of you.

PS: Please take into account that this is working with IBM XL C Compiler and should work on GCC as well

Was it helpful?

Solution

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.

OTHER TIPS

Can you try using only "-static" instead of "-Wl,-static"?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top