3

I was trying to compile Linux Kernel from source. I've compiled the kernel previously and never got any error. But this time I am facing an error. The error is

   CHK     include/generated/asm-offsets.h
   CALL    scripts/checksyscalls.sh
   HOSTCC  scripts/sign-file
  /tmp/cczyW3hq.o: In function `main':
  sign-file.c:(.text.startup+0x52): undefined reference to `OPENSSL_init_crypto'
  sign-file.c:(.text.startup+0x5e): undefined reference to `OPENSSL_init_crypto'
  sign-file.c:(.text.startup+0x247): undefined reference to `OPENSSL_init_crypto'
  collect2: error: ld returned 1 exit status
  scripts/Makefile.host:91: recipe for target 'scripts/sign-file' failed
  make[1]: [scripts/sign-file] Error 1

When I checked scripts/sign-file.c, I saw comment saying Sign a module file using the given key.. So I reran make menuconfig, and set Module signature verification off. And tried to compile again. Now, previous error was removed but new error showed up which was same as above but on different file. Here is the error,

  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  HOSTCC  scripts/extract-cert
  /tmp/ccA63AAC.o: In function `main':
  extract-cert.c:(.text.startup+0x25): undefined reference to `OPENSSL_init_crypto'
  extract-cert.c:(.text.startup+0x31): undefined reference to `OPENSSL_init_crypto'
  collect2: error: ld returned 1 exit status
  scripts/Makefile.host:91: recipe for target 'scripts/extract-cert' failed
  make[1]: *** [scripts/extract-cert] Error 1
  Makefile:556: recipe for target 'scripts' failed
  make: *** [scripts] Error 2

So I want to know whether this problem is with libssl or some configuration error? I am using Ubuntu 16.04LTS with gcc-5.3.1.

EDIT: I have tried reinstalling libssl-dev and also tried compiling openssl from source code and then installing too. I have copied config file from /boot/config-4.4.0-22-generic to source directory.

UPDATE: with make scripts V=1 following is the output:

make -f ./scripts/Makefile.build obj=scripts/basic
rm -f .tmp_quiet_recordmcount
make -f ./scripts/Makefile.asm-generic \
        src=asm obj=arch/x86/include/generated/asm
make -f ./scripts/Makefile.asm-generic \
        src=uapi/asm obj=arch/x86/include/generated/uapi/asm
make -f ./scripts/Makefile.build obj=scripts
make -f ./scripts/Makefile.build obj=scripts/gdb
make -f ./scripts/Makefile.build obj=scripts/gdb/linux
make -f ./scripts/Makefile.build obj=scripts/genksyms
make -f ./scripts/Makefile.build obj=scripts/mod
make -f ./scripts/Makefile.build obj=scripts/selinux
make -f ./scripts/Makefile.build obj=scripts/selinux/genheaders
make -f ./scripts/Makefile.build obj=scripts/selinux/mdp
  gcc -Wp,-MD,scripts/.sign-file.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89   -I./tools/include  -o scripts/sign-file scripts/sign-file.c  -lcrypto
/tmp/cc7o2Y1C.o: In function `main':
sign-file.c:(.text.startup+0x52): undefined reference to `OPENSSL_init_crypto'
sign-file.c:(.text.startup+0x5e): undefined reference to `OPENSSL_init_crypto'
sign-file.c:(.text.startup+0x247): undefined reference to `OPENSSL_init_crypto'
collect2: error: ld returned 1 exit status
scripts/Makefile.host:91: recipe for target 'scripts/sign-file' failed
make[1]: *** [scripts/sign-file] Error 1
Makefile:556: recipe for target 'scripts' failed
make: *** [scripts] Error 2
6
  • Disable the secure boot option
    – GAD3R
    Jun 6, 2016 at 11:00
  • @GAD3R It is disabled in the BIOS.
    – 0x0001
    Jun 6, 2016 at 11:06
  • What does make scripts V=1 say (from the top-level directory)? Jun 6, 2016 at 12:57
  • @StephenKitt I have updated my question?
    – 0x0001
    Jun 6, 2016 at 13:08
  • Thanks, does it work better if you remove libcrypto* from /usr/local/lib (or wherever you installed your manually-built version)? Jun 6, 2016 at 13:17

3 Answers 3

1

Since you enabled kernel module signing, the kernel compilation process is also trying to produce the sign-file tool - and that requires the OpenSSL library.

More specifically, compiling anything that requires OpenSSL means you should have the development package of OpenSSL (usually openssl-dev or openssl-devel, depending on distribution) installed first.

0

You will have to make sure that the symbolic link to libssl and libcrypto is updated. Here is what you should do: Search for all occurrences of libssl.so and libcrypto.so

for each of them, see of they are linking to the correct version of libssl. libssl.so.1.1 in your case (libssl.so.1.1 must exist).

If they are targeting an older version, delete the link and create a new one

ln -s libssl.so.1.1 libssl.so

Same for libcrytpo.

Make sure you search for all occurances of libssl.so (you never know where your code picks it up from)

0

I hope you are having older version of openssl, which does not have the API OPENSSL_init_crypto.

  1. Find the openssl header file openssl/crypto.h in /usr/include or /usr/local/include and check whether OPENSSL_init_crypto API prototype is present in the header file (you can grep like mentioned below).
grep OPENSSL_init_crypto /usr/include -R
grep OPENSSL_init_crypto /usr/local/include -R

If the above 2 grep commands gives no result, then either you are not having openssl installed or installed older openssl version.

  1. So download latest openssl-1.1.1 from here and install using below command.
tar -xvf <openssl_tar_package>
./config
make
make install

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .