How to solve : undefined reference to `MD5_Init’

If you are compiling a c propgram which calculates MD5 using a c program, there are higher chances you will encounter an errors like below,


/tmp/cc1eHvha.o: In function `calculate_file_md5':
md5-calculate.c:(.text+0x7b): undefined reference to `MD5_Init'
md5-calculate.c:(.text+0x9d): undefined reference to `MD5_Update'
md5-calculate.c:(.text+0xe1): undefined reference to `MD5_Final'
collect2: error: ld returned 1 exit status

The MD5 functionality is part of OpenSSL cryptographic library. The OpenSSL crypto library implements a wide range of cryptographic algorithms used in various Internet standards. The services provided by this library are used by the OpenSSL implementations of SSL, TLS and S/MIME, and they have also been used to implement SSH, OpenPGP, and other cryptographic standards. libcrypto consists of a number of sub-libraries that implement the individual algorithms. The functionality includes symmetric encryption, public key cryptography and key agreement, certificate handling, cryptographic hash functions, cryptographic pseudo-random number generator, and various utilities.

Solution : You are missing to link the crypto library ( -lcrypto ) during the command line compilation, hence link the same as,

 $ gcc -o md5-calculate  md5-calculate.c -lcrypto 

u

You may refer to “C program to calculate md5 of a file and check if it matches with predefined / downloaded md5sum

Android Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Commands and Packages Compilation Content Management System - CMS Core Kernel C Programs Development & Build Development Environment Setup Errors & Failures Flutter git Go Language Programs Hardware Platforms HTML JAVA Programs Kernel & Device Drivers Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Monetization / Google AdSense Multimedia - Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized User Interface Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply / Ask Question