Skip to content
Advertisement

Building OpenSSL and LibCURL from sources (Ubuntu) with undefined references

I’m trying to port a .dll project from Windows to Linux and I need to build OpenSSL and cURL STATICALLY. For this, I’ve tried to compile zlib as well but I get some errors I can’t figure out how to solve.

I didn’t use sudo except for zlib‘s $ sudo make install (since I installed it in default location /usr/local/). This is how I installed the 3 of them:

zlib (from $HOME/software/zlib-1.2.11)

  • $ ./configure --static
  • $ make V=1
  • $ make test OK
  • $ sudo make install installed in /usr/local/lib without errors

openSSL1.1.0g (from $HOME/software/openSSL1.1.0g)

  • $ LIBS="-lcrypto -lz -ldl" ./config -fPIC -static --debug zlib no-zlib-dynamic --prefix=$HOME/<project_path>/openssl/openssl_debug_64bit_static-linux enable-ssl2 enable-ssl3 enable-ssl3-method no-shared no-threads
  • $ make V=1
  • $ make test OK
  • $ make install installed where specified without errors

curl (from $HOME/software/curl-7.57.0)

  • $ LIBS="-lssl -lcrypto -lz -ldl" ./configure --disable-shared --with-ssl=$HOME/<project_path>/openssl/openssl_debug_64bit_static-linux --enable-debug --prefix=$HOME/<project_path>/libcurl64-linux/debug/ --without-librtmp --without-ca-bundle --disable-ldap --disable-pthreads --disable-threaded-resolver --enable-static
  • $ make V=1
  • $ make test they took a really long time to run and 4 of them failed, but I checked test cases and they were related to TFTP and multiprotocol (not relevant at first)
  • $ make install installed where specified without errors

I’m still having issues like those:

../src/openssl/openssl_debug_64bit_static-linux/lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_init':
/home/jjimenez/software/openssl-1.1.0g/crypto/comp/c_zlib.c:136: undefined reference to `inflateInit_'
/home/jjimenez/software/openssl-1.1.0g/crypto/comp/c_zlib.c:145: undefined reference to `deflateInit_'
../src/openssl/openssl_debug_64bit_static-linux/lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_finish':
/home/jjimenez/software/openssl-1.1.0g/crypto/comp/c_zlib.c:160: undefined reference to `inflateEnd'
/home/jjimenez/software/openssl-1.1.0g/crypto/comp/c_zlib.c:161: undefined reference to `deflateEnd'
../src/openssl/openssl_debug_64bit_static-linux/lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_compress_block':
/home/jjimenez/software/openssl-1.1.0g/crypto/comp/c_zlib.c:180: undefined reference to `deflate'

Things that I don’t get:

  1. Why the hell does it refer to where I built the source code from (/home/jjimenez/software/openssl-1.1.0g)? It’s supposed to create a static library and put every symbol it needs inside the .a, isn’t it?

  2. If I execute this nm -gC /usr/local/lib/libz.a | grep inflateInit_, I get this output:

00000000000005a0 T inflateInit_ U inflateInit_

However, executing nm -gC libcrypto.a | grep inflateInit_ (from inside where openSSL has been installed) I get:

                 U inflateInit_

From what I’ve found, that T means the symbol is indeed there and it is in the code section. Why is it also present with U (symbol undefined)? Can’t I asume it should be found when linking to this library? There’s something definitely weird here.

Any help would be greatly appreciated.

Advertisement

Answer

Finally, I ended up solving it thanks to a teammate.

Static linking did not work as I thought it would, so zlib symbols were not included in libcrypto.a. I simply had to add the former to the CMake compilation and linker runs fine regarding those errors.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement