0

I try to compile libtcnative on a debian/bullseye machine. It fails and I don't know why. I am not very experienced in compiling C Code and linking.

I followed these instructions from ~/tomcat-native-2.0.3-src/native/BUILDING

Linux / Unix / OSX (static linking)

  1. Build static version of OpenSSL 3.0.0 or later

    ./Configure --prefix=~/natives/openssl enable-fips make make install

  2. Build static version of APR 1.7.0 or later

    ./configure --prefix=~/natives/apr make make install

    Note: APR builds both static and dynamic libraries by default.

  3. Ensure the static APR library is used

    Edit the ~/natives/apr/lib/libapr-1.la file and comment or delete the following sections: dlname='...' and library_names='...'
    This is needed so that libtool picks the static version of the library.

  4. Build tc-native

    ./configure --with-apr=~/natives/apr --with-ssl=~/natives/openssl --prefix=~/natives/tomcat make make install

this is my compile script which works fine until the last step:

sudo su
apt-get install build-essential ant
cd

wget -v4 https://dlcdn.apache.org/apr/apr-1.7.2.tar.gz
tar -xzf apr-1.7.2.tar.gz
cd apr-1.7.2
# See
# https://stackoverflow.com/questions/18091991/error-while-compiling-apache-apr-make-file-not-found
touch libtoolT
./configure --prefix=/opt/lib/apr
make
make install
# see 
# tomcat-native-2.0.3-src/native/BUILDING
sed 's/^dlname=/#&/' -i /opt/lib/apr/lib/libapr-1.la
sed 's/^library_names=/#&/' -i /opt/lib/apr/lib/libapr-1.la
cd

wget -v4 https://www.openssl.org/source/openssl-3.0.8.tar.gz
tar -xzf openssl-3.0.8.tar.gz
cd openssl-3.0.8
./Configure --prefix=/opt/lib/openssl enable-fips
make
make install
cd


wget -v4 https://dlcdn.apache.org/tomcat/tomcat-connectors/native/2.0.3/source/tomcat-native-2.0.3-src.tar.gz
tar -xzf tomcat-native-2.0.3-src.tar.gz
cd tomcat-native-2.0.3-src
ant
cd native
./configure --with-apr=/opt/lib/apr --with-ssl=/opt/lib/openssl --with-java-home=/usr/lib/jvm/java-17-openjdk-amd64/ --prefix=/opt/lib/tomcat 
make

The last part of the output is

/opt/lib/openssl/include/openssl/pem.h:342:5: note: in expansion of macro 'DECLARE_PEM_read_attr'
  342 |     DECLARE_PEM_read_attr(attr, name, type)                                 \
      |     ^~~~~~~~~~~~~~~~~~~~~
/opt/lib/openssl/include/openssl/pem.h:461:1: note: in expansion of macro 'DECLARE_PEM_rw_attr'
  461 | DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, ECPKParameters, EC_GROUP)
      | ^~~~~~~~~~~~~~~~~~~
/bin/bash /opt/lib/apr/build-1/libtool --silent --mode=link --tag=CC  gcc -g -O2 -pthread   -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -g -O2 -DTCNATIVE_LINUX -DHAVE_POLLSET_WAKEUP   -I./include -I/usr/lib/jvm/java-17-openjdk-amd64//include -I/usr/lib/jvm/java-17-openjdk-amd64//include/linux -I/opt/lib/openssl/include  -I/opt/lib/apr/include/apr-1   -version-info 0:3:0    -o libtcnative-2.la -rpath /opt/lib/tomcat/lib src/bb.lo src/error.lo src/jnilib.lo src/pool.lo src/ssl.lo src/sslconf.lo src/sslcontext.lo src/sslutils.lo -L/opt/lib/openssl/lib64 -Wl,-rpath,/opt/lib/openssl/lib64 -lssl -lcrypto /opt/lib/apr/lib/libapr-1.la -lrt -lcrypt  -lpthread -ldl
/usr/bin/ld: /opt/lib/apr/lib/libapr-1.a(procsup.o): warning: relocation against `stdout@@GLIBC_2.2.5' in read-only section `.text'
/usr/bin/ld: /opt/lib/apr/lib/libapr-1.a(proc_mutex.o): relocation R_X86_64_PC32 against symbol `apr_proc_mutex_cleanup' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:71: libtcnative-2.la] Error 1
make[1]: Leaving directory '/root/tomcat-native-2.0.3-src/native'
make: *** [/root/tomcat-native-2.0.3-src/native/build/rules.mk:119: all-recursive] Error 1

I have no clue what is failing here.

Janning Vygen
  • 8,877
  • 9
  • 71
  • 102

0 Answers0