TA static does not link on Ubuntu 20.04Answered

libTurboActivate.a does not link correctly on Ubuntu 20.04.  More specifically, it does not link on any Linux distribution with glibc version ≥ 2.31. 

/usr/bin/ld: bin-linux/x64/libTurboActivate.a(nbtheory.o): in function `CryptoPP::FactoringWorkFactor(unsigned int)':
nbtheory.cpp:(.text._ZN8CryptoPP19FactoringWorkFactorEj+0x2f): undefined reference to `__log_finite'
/usr/bin/ld: bin-linux/x64/libTurboActivate.a(nbtheory.o): in function `CryptoPP::DiscreteLogWorkFactor(unsigned int)':
nbtheory.cpp:(.text._ZN8CryptoPP21DiscreteLogWorkFactorEj+0x2f): undefined reference to `__log_finite'
/usr/bin/ld: bin-linux/x64/libTurboActivate.a(nbtheory.o): in function `CryptoPP::MaurerProvablePrime(CryptoPP::RandomNumberGenerator&, unsigned int)':
nbtheory.cpp:(.text._ZN8CryptoPP19MaurerProvablePrimeERNS_21RandomNumberGeneratorEj+0x3a0): undefined reference to `__exp2_finite'

I have created a simple reproducible test case. To run, download and place TurboActivate-Linux-Static.zip in your working directory, then

docker run --rm=true -w "/home" -v "$(pwd)":/data ubuntu:20.04 bash -c \
 "apt-get update && apt-get install -y build-essential unzip;
  gcc -v;
  unzip /data/TurboActivate-Linux-Static.zip;
  echo '
    #include <TurboActivate.h>
    #include <iostream>
    int main() { TA_GetHandle(NULL); std::cout << \"success\" << std::endl; return 0; }' > test.cpp; 
  g++ -DTURBOACTIVATE_STATIC test.cpp -otest -Lbin-linux/x64  -IAPI/C -lTurboActivate -lrt -lpthread -fno-lto;
  ./test"

If you replace ubuntu:20.04 with ubuntu:18.04, it will link and run correctly. 

It looks like other libraries are having similar problems: https://github.com/google/filament/issues/2146

Possible solutions are recompiling libTurboActivate.a with -fno-builtin or compiling without -ffast-math.

Answer

If you want to use static builds use CentOS 7 with the latest devtoolset (currently 9).

Otherwise you'll need to use the dynamic libraries (which is recommended anyway).

Understood. Hopefully this will be changed in the future considering CentOS 7/8 will be EOL'd late 2021 and CentOS has been, in general, abandoned by RedHat. 

FYI: Dynamic library is far easier to circumvent than the static library which is why we prefer static.

You can verify the dynamic file hash matches a hardcoded value. This will make it exactly as easy to circumvent as a static compilation.