skip to Main Content

I am trying to compile the nwipe project from the following GitHub repository: https://github.com/Knogle/nwipe/tree/master. The compilation process completes successfully on a Fedora system, but fails on an Ubuntu machine with the same version of OpenSSL (greater than 3.0.2), which should support the necessary functions. Both systems have the libdev-ssl package correctly installed.

Here is a snippet of the compilation output on Fedora, where it compiles without errors:

gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -MT aes/aes_ctr_prng.o -MD -MP -MF $depbase.Tpo -c -o aes/aes_ctr_prng.o aes/aes_ctr_prng.c &&
mv -f $depbase.Tpo $depbase.Po
...
gcc -g -O2 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -lcrypto -o nwipe nwipe.o ... -lparted -lpthread -lpanel -lncurses -ltinfo -lconfig

However, on Ubuntu, I encounter linker errors related to OpenSSL functions AES_set_encrypt_key and AES_encrypt, which are marked as deprecated since OpenSSL 3.0 but are still included in the project:

/usr/bin/ld: aes/aes_ctr_prng.o: in function `aes_ctr_prng_init':
/tmp/nwipe/src/aes/aes_ctr_prng.c:22: undefined reference to `AES_set_encrypt_key'
/usr/bin/ld: aes/aes_ctr_prng.o: in function `aes_ctr_prng_genrand_uint32':
/tmp/nwipe/src/aes/aes_ctr_prng.c:41: undefined reference to `AES_encrypt'
/usr/bin/ld: /tmp/nwipe/src/aes/aes_ctr_prng.c:41: undefined reference to `CRYPTO_ctr128_encrypt'
collect2: error: ld returned 1 exit status

Given that the compilation succeeds on Fedora but fails on Ubuntu, despite having the same OpenSSL version and seemingly correct dependencies installed, what could be causing this issue? How can I resolve these linker errors on Ubuntu?

2

Answers


  1. Chosen as BEST ANSWER

    Thanks a lot for your reply already! As mentioned by yourself, the issue was somewhere in the placing of -lcrypto What has solved the issue, was adding the dependency for the autoconf script, in configure.ac Added OpenSSL there, and now it compiles fine! Thanks for your help though.

    KG_CHECK_MODULES(
    [OPENSSL],
    [openssl],
    [
            CFLAGS="${CFLAGS} ${OPENSSL_CFLAGS}"
            LIBS="${LIBS} ${OPENSSL_LIBS}"
    ],
    [AC_CHECK_LIB([ssl], [SSL_library_init], [
            LIBS="-lssl -lcrypto $LIBS"
            AC_CHECK_HEADERS(openssl/ssl.h,, [
                AC_CHECK_HEADERS(openssl/crypto.h, [
                    AC_DEFINE([OPENSSL_IN_SUBDIR], [openssl/], [Look for openssl headers in subdir])
                    ], [AC_MSG_ERROR([openssl headers not found])])
            ])
        ], [AC_MSG_ERROR([OpenSSL development library not found])]
    )]
    

    )


  2. This link command …

    gcc -g -O2 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -lcrypto -o nwipe nwipe.o ... -lparted -lpthread -lpanel -lncurses -ltinfo -lconfig
    

    … places -lcrypto incorrectly on the command line. It should follow all the object files (and any libraries) that call any of its functions. It’s unclear why the build nevertheless works on Fedora, but not at all surprising that it fails on Ubuntu.

    I presume that the project’s build system is responsible for that placement, not you, personally. In that case, you’re looking at a flaw that you should report to the project’s development team.

    Meanwhile, if you feel competent to do so then you could try to fix it yourself, but you have not presented enough information for us to fix it for you.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search