2

I'm try to use Openssl library for gem5.

My SimObject code include two header on Openssl.

#include <openssl/evp.h>
#include <openssl/aes.h>

But there is a link error. Error message is

undefined reference to `EVP_CIPHER_CTX_new'
undefined reference to `EVP_aes_128_ctr'

What we have already done

  1. apt install libssl-dev
  2. apt install libcrypto++6 libcrypto++6-dbg libcrypto++-dev
  3. Added to SConstruct in "if main['GCC']" block main.Append(LDFLAGS =["-L/usr/local/ssl/include"]) main.Append(LDLIBS=["-lcrypto"])

evp.h,and aes.h are in /usr/local/ssl/include/openssl

We would be grateful for your help!

$ openssl version -a

OpenSSL 1.1.1f  31 Mar 2020
built on: Mon Aug 23 17:02:39 2021 UTC
platform: debian-amd64
options:  bn(64,64) rc4(16x,int) des(int) blowfish(ptr)
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -Wa,--noexecstack -g -O2 -fdebug-prefix-map=/build/openssl-JWge0V/openssl-1.1.1f=. -fstack-protector-strong -Wformat -Werror=format-security -DOPENSSL_TLS_SECURITY_LEVEL=2 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DNDEBUG -Wdate-time -D_FORTIFY_SOURCE=2
OPENSSLDIR: "/usr/lib/ssl"
ENGINESDIR: "/usr/lib/x86_64-linux-gnu/engines-1.1"
Seeding source: os-specific
retis
  • 21
  • 1

1 Answers1

0

As you've installed libcrypto through apt-get, it should be in a system library path known to scons, so you shouldn't need to append to LDFLAGS.

You need to link against libcrypto within the SConstruct file. Change main.Append(LDLIBS=["-lcrypto"]) for main.Append(LIBS=["crypto"]). See https://scons.org/doc/production/HTML/scons-user/ch04s02.html for details.

PS: you can pass --verbose to scons to verify the linker command uses -lcrypto correctly.

  • thanks to reply, but your idea doesn't solve my problem. So, i doesn't use openssl lib...... – retis Nov 14 '21 at 13:10