C/C++

How to add preprocessor build flags in PlatformIO

In order to define a preprocessor build flag in PlatformIO, add it to build_flags in platformio.ini, prefixing it with -D:

build_flags = -DQUICKSPI_DEBUG_WRITES

or, in order to define it to a specific value, use

build_flags = -DQUICKSPI_DEBUG_WRITES=1

 

 

Posted by Uli Köhler in C/C++, PlatformIO

How to add FreeRTOS task (“thread”) to any PlatformIO project

Most PlatformIO default configurations already have FreeRTOS enabled – they just don’t use it.

In order to start a new FreeRTOS “thread” (called task in FreeRTOS-speak), first add these includes:

#include <freertos/FreeRTOS.h>
#include <freertos/task.h>

Now add the task function and handle:

TaskHandle_t myTaskHandle;
void MyTask( void * parameter )
{
    for(;;)
    {
       // TODO Task code goes here
    }
    // if you ever exit the loop, this is here to clean up the resources
    vTaskDelete( NULL );
}

then start the task using this code once, for example in your main function:

// Start MyTask thread
xTaskCreate(
    MyTask, // Task function
    "MyTask", // Name
    10000, // Stack size
    NULL, // Parameter
    1, // Priority
    &myTaskHandle);

Also see our new post on how to use xTaskCreateStatic() to use statically allocated instead of dynamically allocated stack memory for the task: FreeRTOS task with static stack memory (xTaskCreateStatic) example

Posted by Uli Köhler in C/C++, Electronics, Embedded, FreeRTOS, PlatformIO

How to read 8-bit I2C register using Arduino Wire library: A minimal example

The following code demonstrates how to read a register that is 1 byte (8 bits) long over I2C. It will work with almost all I2C devices like EEPROMs, ADCs and others, provided you have the correct. Note that some devices like the LAN9303 have a slightly different addressing scheme or other peculiarities. In my opinion, it’s most efficient to just try out the standard way of reading a register and start from there.

Note that this code does not implement error handling for the sake of simplicity. Additionally, we wait for data using delay() instead of Wire.available(). This is a minimal example so it creates minimal confusion for the reader. We will provide a full example with error handling in a followup post.

const uint8_t SLAVE_I2C_ADDRESS = 0b1010;
const uint16_t SLAVE_I2C_REGISTER_ADDRESS = 0x50;

Wire.beginTransmission(SLAVE_I2C_ADDRESS);
Wire.write(SLAVE_I2C_REGISTER_ADDRESS);
Wire.endTransmission();
Wire.requestFrom(SLAVE_I2C_ADDRESS, 1); // This register is 8 bits = 1 byte long
delay(2); // Wait for data to be available
// Read directly into an uint8_t
uint8_t buf = (uint8_t)Wire.read();
// Print register value
Serial.printf("Register value: %02x\r\n", buf);

Also see:

Posted by Uli Köhler in Arduino, C/C++, Electronics, Embedded, PlatformIO

How to read 16-bit I2C register using Arduino Wire library: A minimal example

The following code demonstrates how to read a register that is 2 bytes (16 bits) long over I2C. It will work with almost all I2C devices like EEPROMs, ADCs and others, provided you have the correct. Note that some devices like the LAN9303 have a slightly different addressing scheme or other peculiarities. In my opinion, it’s most efficient to just try out the standard way of reading a register and start from there.

Note that this code does not implement error handling for the sake of simplicity. Additionally, we wait for data using delay() instead of Wire.available(). This is a minimal example so it creates minimal confusion for the reader. We will provide a full example with error handling in a followup post.

Option 1: Reading the register into an uint16_t (recommended)

const uint8_t SLAVE_I2C_ADDRESS = 0b1010;
const uint16_t SLAVE_I2C_REGISTER_ADDRESS = 0x50;

Wire.beginTransmission(SLAVE_I2C_ADDRESS);
Wire.write(SLAVE_I2C_REGISTER_ADDRESS);
Wire.endTransmission();
Wire.requestFrom(SLAVE_I2C_ADDRESS, 2); // This register is 16 bits = 2 bytes long
delay(5); // Wait for data to be available
// Read directly into an uint32_t
uint16_t buf;
Wire.readBytes((uint8_t*)&buf, 2);
// Print register value
Serial.printf("Register value: %04x\r\n", __builtin_bswap16(buf));

For an explanation on why we need __builtin_bswap16(), see How to print 16-bit uint16_t as four hex digits in Arduino

Option 2: Reading the register into an uint8_t array

const uint8_t SLAVE_I2C_ADDRESS = 0b1010;
const uint16_t SLAVE_I2C_REGISTER_ADDRESS = 0x50;

Wire.beginTransmission(SLAVE_I2C_ADDRESS);
Wire.write(SLAVE_I2C_REGISTER_ADDRESS);
Wire.endTransmission();
Wire.requestFrom(SLAVE_I2C_ADDRESS, 2); // This register is 16 bits = 2 bytes long
delay(5); // Wait for data to be available
// Read into a 2-byte buffer
uint8_t buf[2];
Wire.readBytes(buf, 2);
// Print register value
Serial.printf("Register value: %02x%02x\r\n", buf[0], buf[1]);

Also see:

Posted by Uli Köhler in Arduino, C/C++, Electronics, Embedded, PlatformIO

How to read 32-bit I2C register using Arduino Wire library: A minimal example

The following code demonstrates how to read a register that is 4 bytes (32 bits) long over I2C. It will work with almost all I2C devices like EEPROMs, ADCs and others, provided you have the correct. Note that some devices like the LAN9303 have a slightly different addressing scheme or other peculiarities. In my opinion, it’s most efficient to just try out the standard way of reading a register and start from there.

Note that this code does not implement error handling for the sake of simplicity. Additionally, we wait for data using delay() instead of Wire.available(). This is a minimal example so it creates minimal confusion for the reader. We will provide a full example with error handling in a followup post.

Option 1: Reading the register into an uint32_t (recommended)

const uint8_t SLAVE_I2C_ADDRESS = 0b1010;
const uint16_t SLAVE_I2C_REGISTER_ADDRESS = 0x50;

Wire.beginTransmission(SLAVE_I2C_ADDRESS);
Wire.write(SLAVE_I2C_REGISTER_ADDRESS);
Wire.endTransmission();
Wire.requestFrom(SLAVE_I2C_ADDRESS, 4); // This register is 32 bits = 4 bytes long
delay(5); // Wait for data to be available
// Read directly into an uint32_t
uint32_t buf;
size_t actually_read = Wire.readBytes((uint8_t*)&buf, 4);
// Print register value
Serial.printf("Register value: %08lx\r\n", __builtin_bswap32(buf));

For an explanation on why we need __builtin_bswap32(), see How to print 32-bit uint32_t as eight hex digits in Arduino

Option 2: Reading the register into an uint8_t array

const uint8_t SLAVE_I2C_ADDRESS = 0b1010;
const uint16_t SLAVE_I2C_REGISTER_ADDRESS = 0x50;

Wire.beginTransmission(SLAVE_I2C_ADDRESS);
Wire.write(SLAVE_I2C_REGISTER_ADDRESS);
Wire.endTransmission();
Wire.requestFrom(SLAVE_I2C_ADDRESS, 4); // This register is 32 bits = 4 bytes long
delay(5); // Wait for data to be available
// Read into a 4-byte buffer
uint8_t buf[4];
size_t actually_read = Wire.readBytes(buf, 4);
// Print register value
Serial.printf("Register value: %02x%02x%02x%02x\r\n", buf[0], buf[1], buf[2], buf[3]);

Also see:

Posted by Uli Köhler in Arduino, C/C++, Electronics, Embedded, PlatformIO

How to access LAN9303 registers over I2C using Arduino / PlatformIO

The LAN9303 has some peculiarities when accessing its registers. This post will not cover indirect register access but only access to the registers which are directly accessible over I2C. Note that the prerequisite for this is to configure the LAN9303 into a mode where management over the I2C slave interface is enabled. See How to get the LAN9303 into I2C managed mode for more info on how to do that.

The main point to take away is that you do not write the register offset from the datasheet (such as 0x50 for the Chip ID and revision register) in the I2C address byte but the address divided by 4 (0x50 >> 2 == 0x14). This is evidenced by figure 8-8 from the datasheet, copyright Microchip, listing the address byte as A[9:2] as opposed to the standard A[7:0]:

 

Example on how to access the register at offset 0x50 (Chip ID and revision register) in Arduino using the Wire library:

const uint8_t LAN9303_I2C_ADDRESS = 0b1010;
const uint16_t LAN9303_CHIPID_REV_Register = 0x50;

Wire.beginTransmission(LAN9303_I2C_ADDRESS);
Wire.write(LAN9303_CHIPID_REV_Register >> 2);
Wire.endTransmission();
Wire.requestFrom(LAN9303_I2C_ADDRESS, 4); // This register is 32 bits = 4 bytes long
delay(5); // Wait for data to be available

// Read directly into an uint8_t
uint32_t buf;
size_t actually_read = Wire.readBytes((uint8_t*)&buf, 4);
// Check if we have received all 4 bytes
if(actually_read != 4) {
    Serial.println("Did not read enough bytes");
}

// Print register value
Serial.printf("LAN9303 Chip ID and revision: %08lx\r\n", __builtin_bswap32(buf));

This will print

LAN9303 Chip ID and revision: 93030001

in other words: Chip ID = 0x9303, revision = 0x0001

 

Posted by Uli Köhler in Arduino, C/C++, Electronics, Embedded, Networking, PlatformIO

Teensy 4.x Quadrature Encoder minimal example in PlatformIO/Arduino

This example uses PlatformIO and the Teensy-4.x-Quad-Encoder-Library to implement a hardware quadrature encoder on pins 0 and 1. Remember that the teensy will be destroyed if you use 5V encoder signals. You can only use 3.3V signals!

#include <Arduino.h>
#include <QuadEncoder.h>

QuadEncoder encoder(1, 0, 1, 0);

void setup() {
    Serial.begin(115200);
    encoder.setInitConfig();
    encoder.init();
}

void loop() {
    int32_t position = encoder.read();
    // Compute position in mm and print it
    constexpr float mm_per_count = 0.0012;
    float mm = position * mm_per_count;
    Serial.printf("Position: %+3.4f (count %ld)\r\n", mm, position);
    // Print every 50ms
    delay(50);
}
[env:teensy41]
platform = teensy
board = teensy41
framework = arduino
monitor_speed = 115200
lib_deps =
    git+https://github.com/mjs513/Teensy-4.x-Quad-Encoder-Library

 

Posted by Uli Köhler in C/C++, Electronics, Embedded, PlatformIO, Teensy

How to use HAL_GPIO_Init() in modern C++ (STM32)

In modern C++, you can directly initialize structs like a GPIO_InitTypeDef, making the code much prettier and less prone to errors. The following example configures PA8 of a STM32 in alternate function 1 mode (TIM1 output).

GPIO_InitTypeDef pinInit = {
  .Pin = GPIO_PIN_8,
  .Mode = GPIO_MODE_AF_PP,
  .Pull = GPIO_NOPULL,
  .Speed = GPIO_SPEED_FREQ_VERY_HIGH,
  .Alternate = GPIO_AF1_TIM1
};
HAL_GPIO_Init(GPIOA, &pinInit);

As opposed to the old, much more verbose way of doing that:

GPIO_InitTypeDef pinInit;
pinInit.Pin = GPIO_PIN_8;
pinInit.Mode = GPIO_MODE_AF_PP;
pinInit.Pull = GPIO_NOPULL;
pinInit.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
pinInit.Alternate = GPIO_AF1_TIM1;
HAL_GPIO_Init(GPIOA, &pinInit);

 

 

Posted by Uli Köhler in C/C++, Electronics, STM32

How to use ESP32 as USB-to-UART converter in PlatformIO

The ESP32 can easily be used as USB-to-UART converter. Note that the ESP32 does not feature an USB interface by itself and ESP32 boards with an onboard USB connector just use an USB-to-UART converter (this is a separate chip on the board). Hence, from the ESP32 perspective, it

You can map UART TX and RX to any GPIO pin on the ESP32. While there are very, very slight performance advantages to using a set of predefined pins, this does not really matter in practice. In this example, we will use pin GPIO2 for UART RX and pin GPIO4 for UART TX.

Basically, the code is just copying bytes between Serial2 and Serial (connected to USB):

// Copy bytes incoming via PC serial
while (Serial.available() > 0) {
  Serial2.write(Serial.read());
}
// Copy bytes incoming via UART serial
while (Serial2.available() > 0) {
  Serial.write(Serial2.read());
}

Full example

#include <Arduino.h>

#define UART_RX_PIN 2 // GPIO2
#define UART_TX_PIN 4 // GPIO4

void setup() {
  // Serial connects to the computer
  Serial.begin(115200);
  // Serial2 is the hardware UART port that connects to external circuitry
  Serial2.begin(115200, SERIAL_8N1,
                UART_RX_PIN,
                UART_TX_PIN);
}

void loop() {
  // Copy byte incoming via PC serial
  while (Serial.available() > 0) {
    Serial2.write(Serial.read());
  }
  // Copy bytes incoming via UART serial
  while (Serial2.available() > 0) {
    Serial.write(Serial2.read());
  }
}

Regarding platformio.ini, we just need to set the monitor_speed to match the value in Serial.begin(115200);:

[env:nodemcu-32s]
platform = espressif32
board = nodemcu-32s
framework = arduino
monitor_speed = 115200

 

Posted by Uli Köhler in C/C++, Electronics, ESP8266/ESP32, PlatformIO

Implementing STM32 DFU bootloader firmware upgrade in Marlin using M997

Marlin implements the M997 command which is intended to switch the mainboard into a firmware upgrade mode.

All STM32 variants have an integrated (hard-coded – so no need to flash it yourself) bootloader that is notoriously difficult to active.

However, Marlin implements M997 on the STM32 as just a reboot:

void flashFirmware(const int16_t) { HAL_reboot(); }

This only works if you are using a custom bootloader on your board – however, it does not use the STM32 integrated bootloader.

The following code was tested on the STM32F446 (BigTreeTech Octopus V1) but should work on any STM32 variant. It is based on previous work by Dave Hyland on StackOverflow. Replace the default flashFirmware() function in Marlin/src/HAL/STM32/HAL.cpp

void flashFirmware(const int16_t) {
    HAL_RCC_DeInit();
    HAL_DeInit();

    __HAL_REMAPMEMORY_SYSTEMFLASH();

    // arm-none-eabi-gcc 4.9.0 does not correctly inline this
    // MSP function, so we write it out explicitly here.
    //__set_MSP(*((uint32_t*) 0x00000000));
    __ASM volatile ("movs r3, #0\nldr r3, [r3, #0]\nMSR msp, r3\n" : : : "r3", "sp");

    ((void (*)(void)) *((uint32_t*) 0x00000004))();

    // This will never be executed
    HAL_reboot();
}

Note that we left a HAL_reboot() call as a safeguard at the end, just in case the previous calls fail.

On my BigTreeTech Octopus V1 (STM32F446), by using this code, you can successfully enter the integrated DFU bootloader.

Also see our previous posts on how to use the STM32 in DFU bootloader mode:

Posted by Uli Köhler in 3D printing, C/C++, STM32

How to implement 1MHz interrupt in PlatformIO / Arduino on STM32

In our previous post Minimal STM32 HardwareTimer PlatformIO / Arduino timer interrupt blink example we showed how to use HardwareTimer to blink the onboard LED of our STM32F407 board using a timer interrupt.

In this post, we’ll provide an example of how to use HardwareTimer and have a really fast interrupt which runs at 1 MHz – in other words: one million times per second.

#include <Arduino.h>

HardwareTimer timer(TIM1);
bool ledOn = false;

void OnTimer1Interrupt() {
    ledOn = !ledOn;
    digitalWrite(PC13, ledOn ? HIGH : LOW);
}

void setup() {
    pinMode(PC13, OUTPUT);
    // Configure timer
    timer.setPrescaleFactor(21); // Set prescaler to 21 => timer frequency = 168/21 = 8 MHz (from prediv'd by 1 clocksource of 168 MHz)
    timer.setOverflow(8); // Set ARR to 8 => timer frequency = 1 MHz
    timer.attachInterrupt(OnTimer1Interrupt);
    timer.refresh(); // Make register changes take effect
    timer.resume(); // Start timre
}

void loop() {
}

Note that when running such a quick interrupt, you can’t do all too much within the interrupt before the next time the interrupt will run.

Posted by Uli Köhler in C/C++, PlatformIO, STM32

How to use STM32 _Msk and _Pos definitions to read and write registers

The STM32 HAL contains definitions like TIM_CR1_CKD_Msk or TIM_CR1_CKD_Pos which you can use to make it easier to read or write parts of a register.

Reading a part of a register

uint32_t ckd = (TIM1->CR1 & TIM_CR1_CKD_Msk) >> TIM_CR1_CKD_Pos;

Writing a part of a register

uint32_t new_ckd_value = TIM_CLOCKDIVISION_DIV4; // example
TIM1->CR1 &= TIM_CR1_CKD_Msk; // Clear bits
TIM1->CR1 |= new_ckd_value << TIM_CR1_CKD_Pos; // Set bits

 

Posted by Uli Köhler in C/C++, STM32

How to create conan debug profile

Run this command to create a debug profile from your default profile:

cp ~/.conan/profiles/default ~/.conan/profiles/debug && sed -i -e 's/Release/Debug/g' ~/.conan/profiles/debug

Example output from conan profile show debug:

[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=9
compiler.libcxx=libstdc++
build_type=Debug
[options]
[conf]
[build_requires]
[env]

 

Posted by Uli Köhler in C/C++, Conan

How to get time since epoch in milliseconds in C++

Use this snippet using chrono:

#include <chrono>

uint64_t timeSinceEpochMilliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(
    std::chrono::system_clock::now().time_since_epoch()
).count();

 

Posted by Uli Köhler in C/C++

How to fix C++ error “undefined reference to `dlopen'”

Problem:

When compiling your C++ application, you see one or more of the following or similar error messages (complete error message log example shown below)

dso_dlfcn.c:(.text+0x17): undefined reference to `dlopen'
/usr/bin/ld: dso_dlfcn.c:(.text+0x2a): undefined reference to `dlsym'
/usr/bin/ld: dso_dlfcn.c:(.text+0x35): undefined reference to `dlclose'
dso_dlfcn.c:(.text+0x1b7): undefined reference to `dlsym'
/usr/bin/ld: dso_dlfcn.c:(.text+0x282): undefined reference to `dlerror'
dso_dlfcn.c:(.text+0x2f5): undefined reference to `dlopen'
/usr/bin/ld: dso_dlfcn.c:(.text+0x369): undefined reference to `dlclose'
/usr/bin/ld: dso_dlfcn.c:(.text+0x3a5): undefined reference to `dlerror'
dso_dlfcn.c:(.text+0x466): undefined reference to `dladdr'
/usr/bin/ld: dso_dlfcn.c:(.text+0x4d7): undefined reference to `dlerror'

Solution:

You need to link the dl (dynamic linker) library to your executable. When running gcc manually, use the -ldl option, for example:

gcc -o myexe main.cpp -ldl

When using CMake, use

add_executable(myexe main.cpp)
target_link_libraries(myexe dl)

Full error log example:

/usr/bin/ld: /home/uli/.conan/data/openssl/1.1.1k/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libcrypto.a(dso_dlfcn.o): in function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x17): undefined reference to `dlopen'
/usr/bin/ld: dso_dlfcn.c:(.text+0x2a): undefined reference to `dlsym'
/usr/bin/ld: dso_dlfcn.c:(.text+0x35): undefined reference to `dlclose'
/usr/bin/ld: /home/uli/.conan/data/openssl/1.1.1k/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libcrypto.a(dso_dlfcn.o): in function `dlfcn_bind_func':
dso_dlfcn.c:(.text+0x1b7): undefined reference to `dlsym'
/usr/bin/ld: dso_dlfcn.c:(.text+0x282): undefined reference to `dlerror'
/usr/bin/ld: /home/uli/.conan/data/openssl/1.1.1k/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libcrypto.a(dso_dlfcn.o): in function `dlfcn_load':
dso_dlfcn.c:(.text+0x2f5): undefined reference to `dlopen'
/usr/bin/ld: dso_dlfcn.c:(.text+0x369): undefined reference to `dlclose'
/usr/bin/ld: dso_dlfcn.c:(.text+0x3a5): undefined reference to `dlerror'
/usr/bin/ld: /home/uli/.conan/data/openssl/1.1.1k/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libcrypto.a(dso_dlfcn.o): in function `dlfcn_pathbyaddr':
dso_dlfcn.c:(.text+0x466): undefined reference to `dladdr'
/usr/bin/ld: dso_dlfcn.c:(.text+0x4d7): undefined reference to `dlerror'
/usr/bin/ld: /home/uli/.conan/data/openssl/1.1.1k/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libcrypto.a(dso_dlfcn.o): in function `dlfcn_unload':
dso_dlfcn.c:(.text+0x6b8): undefined reference to `dlclose'
Posted by Uli Köhler in C/C++, GCC errors

How to fix C++ error “undefined reference to `pthread_rwlock_init'”

Problem:

When compiling your C++ application, you see one or more of the following or similar error messages (complete error message log example shown below)

threads_pthread.c:(.text+0x4a): undefined reference to `pthread_rwlock_init'
threads_pthread.c:(.text+0x89): undefined reference to `pthread_rwlock_rdlock'
threads_pthread.c:(.text+0xa9): undefined reference to `pthread_rwlock_wrlock'
threads_pthread.c:(.text+0xc9): undefined reference to `pthread_rwlock_unlock'
threads_pthread.c:(.text+0xee): undefined reference to `pthread_rwlock_destroy'
threads_pthread.c:(.text+0x129): undefined reference to `pthread_once'
threads_pthread.c:(.text+0x149): undefined reference to `pthread_key_create'
threads_pthread.c:(.text+0x17b): undefined reference to `pthread_setspecific'
threads_pthread.c:(.text+0x19b): undefined reference to `pthread_key_delete'
threads_pthread.c:(.text+0x207): undefined reference to `pthread_once'
threads_pthread.c:(.text+0x167): undefined reference to `pthread_getspecific'

Solution:

You need to link the pthread library to your executable. When running gcc manually, use the -lpthread option, for example:

gcc -o myexe main.cpp -lpthread

When using CMake, use

add_executable(myexe main.cpp)
target_link_libraries(myexe pthread)

Full error log example:

/usr/bin/ld: /home/uli/.conan/data/openssl/1.1.1k/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_lock_new':
threads_pthread.c:(.text+0x4a): undefined reference to `pthread_rwlock_init'
/usr/bin/ld: /home/uli/.conan/data/openssl/1.1.1k/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_read_lock':
threads_pthread.c:(.text+0x89): undefined reference to `pthread_rwlock_rdlock'
/usr/bin/ld: /home/uli/.conan/data/openssl/1.1.1k/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_write_lock':
threads_pthread.c:(.text+0xa9): undefined reference to `pthread_rwlock_wrlock'
/usr/bin/ld: /home/uli/.conan/data/openssl/1.1.1k/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_unlock':
threads_pthread.c:(.text+0xc9): undefined reference to `pthread_rwlock_unlock'
/usr/bin/ld: /home/uli/.conan/data/openssl/1.1.1k/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_lock_free':
threads_pthread.c:(.text+0xee): undefined reference to `pthread_rwlock_destroy'
/usr/bin/ld: /home/uli/.conan/data/openssl/1.1.1k/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_run_once':
threads_pthread.c:(.text+0x129): undefined reference to `pthread_once'
/usr/bin/ld: /home/uli/.conan/data/openssl/1.1.1k/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_init_local':
threads_pthread.c:(.text+0x149): undefined reference to `pthread_key_create'
/usr/bin/ld: /home/uli/.conan/data/openssl/1.1.1k/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_set_local':
threads_pthread.c:(.text+0x17b): undefined reference to `pthread_setspecific'
/usr/bin/ld: /home/uli/.conan/data/openssl/1.1.1k/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_cleanup_local':
threads_pthread.c:(.text+0x19b): undefined reference to `pthread_key_delete'
/usr/bin/ld: /home/uli/.conan/data/openssl/1.1.1k/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libcrypto.a(threads_pthread.o): in function `openssl_init_fork_handlers':
threads_pthread.c:(.text+0x207): undefined reference to `pthread_once'
/usr/bin/ld: /home/uli/.conan/data/openssl/1.1.1k/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_get_local':
threads_pthread.c:(.text+0x167): undefined reference to `pthread_getspecific'
/usr/bin/ld: /home/uli/.conan/data/openssl/1.1.1k/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libcrypto.a(dso_dlfcn.o): in function `dlfcn_globallookup':

 

Posted by Uli Köhler in C/C++, GCC errors

How to fix C++ error “undefined reference to `MD5_Update'”

Problem:

When compiling your C++ application, you see one or more of the following or similar error messages (complete error message log example shown below)

/usr/bin/ld: md5.c:(.text+0x44): undefined reference to `MD5_Update'
/usr/bin/ld: md5.c:(.text+0x4f): undefined reference to `MD5_Final'
sha256.c:(.text+0x32): undefined reference to `SHA256_Init'
/usr/bin/ld: sha256.c:(.text+0x47): undefined reference to `SHA256_Update'
/usr/bin/ld: sha256.c:(.text+0x52): undefined reference to `SHA256_Final

Solution:

You need to link OpenSSL to your executable – the libraries that need to be linked are called crypto (libcrypto.so) and ssl (libssl.so). When running gcc manually, use the -lcrypto and -lssl options, for example:

gcc -o myexe main.cpp -lcrypto -lssl

When using CMake, use

add_executable(myexe main.cpp)
target_link_libraries(myexe crypto ssl)

Full error log example:

/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-md5.o): in function `Curl_md5it':
md5.c:(.text+0x2f): undefined reference to `MD5_Init'
/usr/bin/ld: md5.c:(.text+0x44): undefined reference to `MD5_Update'
/usr/bin/ld: md5.c:(.text+0x4f): undefined reference to `MD5_Final'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-md5.o):(.data.rel.ro+0x0): undefined reference to `MD5_Init'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-md5.o):(.data.rel.ro+0x8): undefined reference to `MD5_Update'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-md5.o):(.data.rel.ro+0x10): undefined reference to `MD5_Final'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-md5.o):(.data.rel.ro+0x20): undefined reference to `MD5_Init'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-md5.o):(.data.rel.ro+0x28): undefined reference to `MD5_Update'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-md5.o):(.data.rel.ro+0x30): undefined reference to `MD5_Final'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-sha256.o): in function `Curl_sha256it':
sha256.c:(.text+0x32): undefined reference to `SHA256_Init'
/usr/bin/ld: sha256.c:(.text+0x47): undefined reference to `SHA256_Update'
/usr/bin/ld: sha256.c:(.text+0x52): undefined reference to `SHA256_Final'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `Curl_ossl_sha256sum':
openssl.c:(.text+0x61): undefined reference to `EVP_MD_CTX_new'
/usr/bin/ld: openssl.c:(.text+0x69): undefined reference to `EVP_sha256'
/usr/bin/ld: openssl.c:(.text+0x76): undefined reference to `EVP_DigestInit_ex'
/usr/bin/ld: openssl.c:(.text+0x84): undefined reference to `EVP_DigestUpdate'
/usr/bin/ld: openssl.c:(.text+0x94): undefined reference to `EVP_DigestFinal_ex'
/usr/bin/ld: openssl.c:(.text+0x9c): undefined reference to `EVP_MD_CTX_free'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `Curl_ossl_md5sum':
openssl.c:(.text+0x101): undefined reference to `EVP_MD_CTX_new'
/usr/bin/ld: openssl.c:(.text+0x109): undefined reference to `EVP_md5'
/usr/bin/ld: openssl.c:(.text+0x116): undefined reference to `EVP_DigestInit_ex'
/usr/bin/ld: openssl.c:(.text+0x124): undefined reference to `EVP_DigestUpdate'
/usr/bin/ld: openssl.c:(.text+0x134): undefined reference to `EVP_DigestFinal_ex'
/usr/bin/ld: openssl.c:(.text+0x13c): undefined reference to `EVP_MD_CTX_free'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `Curl_ossl_engines_list':
openssl.c:(.text+0x17a): undefined reference to `ENGINE_get_first'
/usr/bin/ld: openssl.c:(.text+0x194): undefined reference to `ENGINE_get_next'
/usr/bin/ld: openssl.c:(.text+0x1a7): undefined reference to `ENGINE_get_id'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `Curl_ossl_close_all':
openssl.c:(.text+0x1f5): undefined reference to `ENGINE_finish'
/usr/bin/ld: openssl.c:(.text+0x201): undefined reference to `ENGINE_free'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `ssl_tls_trace':
openssl.c:(.text+0x446): undefined reference to `SSL_alert_desc_string_long'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `ssl_ui_writer':
openssl.c:(.text+0x645): undefined reference to `UI_get_string_type'
/usr/bin/ld: openssl.c:(.text+0x652): undefined reference to `UI_OpenSSL'
/usr/bin/ld: openssl.c:(.text+0x65a): undefined reference to `UI_method_get_writer'
/usr/bin/ld: openssl.c:(.text+0x674): undefined reference to `UI_get0_user_data'
/usr/bin/ld: openssl.c:(.text+0x681): undefined reference to `UI_get_input_flags'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `ssl_ui_reader':
openssl.c:(.text+0x6b3): undefined reference to `UI_get_string_type'
/usr/bin/ld: openssl.c:(.text+0x6c0): undefined reference to `UI_OpenSSL'
/usr/bin/ld: openssl.c:(.text+0x6c8): undefined reference to `UI_method_get_reader'
/usr/bin/ld: openssl.c:(.text+0x6e4): undefined reference to `UI_get0_user_data'
/usr/bin/ld: openssl.c:(.text+0x6f4): undefined reference to `UI_get_input_flags'
/usr/bin/ld: openssl.c:(.text+0x706): undefined reference to `UI_set_result'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `Curl_ossl_data_pending':
openssl.c:(.text+0x746): undefined reference to `SSL_pending'
/usr/bin/ld: openssl.c:(.text+0x76f): undefined reference to `SSL_pending'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `Curl_ossl_version':
openssl.c:(.text+0x7a9): undefined reference to `OpenSSL_version_num'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `Curl_ossl_set_engine_default':
openssl.c:(.text+0x903): undefined reference to `ENGINE_set_default'
/usr/bin/ld: openssl.c:(.text+0x913): undefined reference to `ENGINE_get_id'
/usr/bin/ld: openssl.c:(.text+0x941): undefined reference to `ENGINE_get_id'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `Curl_ossl_seed.part.0':
openssl.c:(.text+0xbfe): undefined reference to `RAND_add'
/usr/bin/ld: openssl.c:(.text+0xc03): undefined reference to `RAND_status'
/usr/bin/ld: openssl.c:(.text+0xc1f): undefined reference to `RAND_file_name'
/usr/bin/ld: openssl.c:(.text+0xc35): undefined reference to `RAND_load_file'
/usr/bin/ld: openssl.c:(.text+0xc3a): undefined reference to `RAND_status'
/usr/bin/ld: openssl.c:(.text+0xc56): undefined reference to `RAND_status'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `ossl_recv':
openssl.c:(.text+0xde7): undefined reference to `ERR_clear_error'
/usr/bin/ld: openssl.c:(.text+0xe15): undefined reference to `SSL_read'
/usr/bin/ld: openssl.c:(.text+0xe5f): undefined reference to `SSL_get_error'
/usr/bin/ld: openssl.c:(.text+0xe74): undefined reference to `ERR_get_error'
/usr/bin/ld: openssl.c:(.text+0xfc4): undefined reference to `ERR_error_string_n'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `Curl_ossl_close':
openssl.c:(.text+0x102d): undefined reference to `SSL_shutdown'
/usr/bin/ld: openssl.c:(.text+0x103b): undefined reference to `SSL_set_connect_state'
/usr/bin/ld: openssl.c:(.text+0x1049): undefined reference to `SSL_free'
/usr/bin/ld: openssl.c:(.text+0x1063): undefined reference to `SSL_CTX_free'
/usr/bin/ld: openssl.c:(.text+0x1089): undefined reference to `SSL_shutdown'
/usr/bin/ld: openssl.c:(.text+0x1096): undefined reference to `SSL_set_connect_state'
/usr/bin/ld: openssl.c:(.text+0x10a3): undefined reference to `SSL_free'
/usr/bin/ld: openssl.c:(.text+0x10bc): undefined reference to `SSL_CTX_free'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `Curl_ossl_random':
openssl.c:(.text+0x10fb): undefined reference to `RAND_bytes'
/usr/bin/ld: openssl.c:(.text+0x111c): undefined reference to `RAND_status'
/usr/bin/ld: openssl.c:(.text+0x113f): undefined reference to `RAND_load_file'
/usr/bin/ld: openssl.c:(.text+0x1144): undefined reference to `RAND_status'
/usr/bin/ld: openssl.c:(.text+0x1161): undefined reference to `RAND_status'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `ossl_new_session_cb':
openssl.c:(.text+0x11c7): undefined reference to `SSL_get_ex_data'
/usr/bin/ld: openssl.c:(.text+0x11dd): undefined reference to `SSL_get_ex_data'
/usr/bin/ld: openssl.c:(.text+0x123f): undefined reference to `CRYPTO_get_ex_new_index'
/usr/bin/ld: openssl.c:(.text+0x126f): undefined reference to `CRYPTO_get_ex_new_index'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `Curl_ossl_init':
openssl.c:(.text+0x138c): undefined reference to `OPENSSL_load_builtin_modules'
/usr/bin/ld: openssl.c:(.text+0x1391): undefined reference to `ENGINE_load_builtin_engines'
/usr/bin/ld: openssl.c:(.text+0x139f): undefined reference to `CONF_modules_load_file'
/usr/bin/ld: openssl.c:(.text+0x13e7): undefined reference to `CRYPTO_get_ex_new_index'
/usr/bin/ld: openssl.c:(.text+0x1487): undefined reference to `CRYPTO_get_ex_new_index'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `Curl_ossl_set_engine':
openssl.c:(.text+0x14cf): undefined reference to `ENGINE_by_id'
/usr/bin/ld: openssl.c:(.text+0x14ec): undefined reference to `ENGINE_finish'
/usr/bin/ld: openssl.c:(.text+0x14f8): undefined reference to `ENGINE_free'
/usr/bin/ld: openssl.c:(.text+0x150b): undefined reference to `ENGINE_init'
/usr/bin/ld: openssl.c:(.text+0x154f): undefined reference to `ENGINE_free'
/usr/bin/ld: openssl.c:(.text+0x1554): undefined reference to `ERR_get_error'
/usr/bin/ld: openssl.c:(.text+0x156b): undefined reference to `ERR_error_string_n'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `Curl_ossl_shutdown':
openssl.c:(.text+0x16b8): undefined reference to `SSL_free'
/usr/bin/ld: openssl.c:(.text+0x1701): undefined reference to `ERR_clear_error'
/usr/bin/ld: openssl.c:(.text+0x171e): undefined reference to `SSL_read'
/usr/bin/ld: openssl.c:(.text+0x1730): undefined reference to `SSL_get_error'
/usr/bin/ld: openssl.c:(.text+0x177b): undefined reference to `ERR_get_error'
/usr/bin/ld: openssl.c:(.text+0x1831): undefined reference to `SSL_get_shutdown'
/usr/bin/ld: openssl.c:(.text+0x1861): undefined reference to `SSL_shutdown'
/usr/bin/ld: openssl.c:(.text+0x1895): undefined reference to `ERR_error_string_n'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `ossl_connect_step2':
openssl.c:(.text+0x1a13): undefined reference to `ERR_clear_error'
/usr/bin/ld: openssl.c:(.text+0x1a2c): undefined reference to `SSL_connect'
/usr/bin/ld: openssl.c:(.text+0x1a47): undefined reference to `SSL_get_error'
/usr/bin/ld: openssl.c:(.text+0x1af2): undefined reference to `ERR_get_error'
/usr/bin/ld: openssl.c:(.text+0x1b24): undefined reference to `SSL_get_verify_result'
/usr/bin/ld: openssl.c:(.text+0x1b44): undefined reference to `X509_verify_cert_error_string'
/usr/bin/ld: openssl.c:(.text+0x1bf7): undefined reference to `SSL_get_current_cipher'
/usr/bin/ld: openssl.c:(.text+0x1bff): undefined reference to `SSL_CIPHER_get_name'
/usr/bin/ld: openssl.c:(.text+0x1c1e): undefined reference to `SSL_version'
/usr/bin/ld: openssl.c:(.text+0x1c96): undefined reference to `SSL_get0_alpn_selected'
/usr/bin/ld: openssl.c:(.text+0x1d2e): undefined reference to `ERR_error_string_n'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `ossl_send':
openssl.c:(.text+0x1fe6): undefined reference to `ERR_clear_error'
/usr/bin/ld: openssl.c:(.text+0x2015): undefined reference to `SSL_write'
/usr/bin/ld: openssl.c:(.text+0x205e): undefined reference to `SSL_get_error'
/usr/bin/ld: openssl.c:(.text+0x2080): undefined reference to `ERR_get_error'
/usr/bin/ld: openssl.c:(.text+0x20ff): undefined reference to `ERR_get_error'
/usr/bin/ld: openssl.c:(.text+0x219b): undefined reference to `ERR_error_string_n'
/usr/bin/ld: openssl.c:(.text+0x2213): undefined reference to `ERR_error_string_n'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `servercert':
openssl.c:(.text+0x249b): undefined reference to `BIO_s_mem'
/usr/bin/ld: openssl.c:(.text+0x24a3): undefined reference to `BIO_new'
/usr/bin/ld: openssl.c:(.text+0x24cc): undefined reference to `SSL_get_peer_certificate'
/usr/bin/ld: openssl.c:(.text+0x2541): undefined reference to `X509_get_subject_name'
/usr/bin/ld: openssl.c:(.text+0x2549): undefined reference to `BIO_s_mem'
/usr/bin/ld: openssl.c:(.text+0x2551): undefined reference to `BIO_new'
/usr/bin/ld: openssl.c:(.text+0x2576): undefined reference to `X509_NAME_print_ex'
/usr/bin/ld: openssl.c:(.text+0x2596): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x25d6): undefined reference to `BIO_free'
/usr/bin/ld: openssl.c:(.text+0x2614): undefined reference to `X509_get0_notBefore'
/usr/bin/ld: openssl.c:(.text+0x2624): undefined reference to `ASN1_TIME_print'
/usr/bin/ld: openssl.c:(.text+0x2636): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x2663): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x2670): undefined reference to `X509_get0_notAfter'
/usr/bin/ld: openssl.c:(.text+0x267b): undefined reference to `ASN1_TIME_print'
/usr/bin/ld: openssl.c:(.text+0x268d): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x26ba): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x26c2): undefined reference to `BIO_free'
/usr/bin/ld: openssl.c:(.text+0x2786): undefined reference to `X509_get_ext_d2i'
/usr/bin/ld: openssl.c:(.text+0x279a): undefined reference to `OPENSSL_sk_num'
/usr/bin/ld: openssl.c:(.text+0x27ef): undefined reference to `OPENSSL_sk_value'
/usr/bin/ld: openssl.c:(.text+0x281c): undefined reference to `GENERAL_NAMES_free'
/usr/bin/ld: openssl.c:(.text+0x283c): undefined reference to `X509_get_issuer_name'
/usr/bin/ld: openssl.c:(.text+0x2844): undefined reference to `BIO_s_mem'
/usr/bin/ld: openssl.c:(.text+0x284c): undefined reference to `BIO_new'
/usr/bin/ld: openssl.c:(.text+0x286a): undefined reference to `X509_NAME_print_ex'
/usr/bin/ld: openssl.c:(.text+0x2888): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x28c7): undefined reference to `BIO_free'
/usr/bin/ld: openssl.c:(.text+0x2913): undefined reference to `BIO_s_file'
/usr/bin/ld: openssl.c:(.text+0x291b): undefined reference to `BIO_new'
/usr/bin/ld: openssl.c:(.text+0x2956): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x296c): undefined reference to `PEM_read_bio_X509'
/usr/bin/ld: openssl.c:(.text+0x298d): undefined reference to `X509_check_issued'
/usr/bin/ld: openssl.c:(.text+0x29cb): undefined reference to `BIO_free'
/usr/bin/ld: openssl.c:(.text+0x29d3): undefined reference to `X509_free'
/usr/bin/ld: openssl.c:(.text+0x29e5): undefined reference to `SSL_get_verify_result'
/usr/bin/ld: openssl.c:(.text+0x2a3b): undefined reference to `X509_verify_cert_error_string'
/usr/bin/ld: openssl.c:(.text+0x2b08): undefined reference to `X509_get_X509_PUBKEY'
/usr/bin/ld: openssl.c:(.text+0x2b12): undefined reference to `i2d_X509_PUBKEY'
/usr/bin/ld: openssl.c:(.text+0x2b3f): undefined reference to `X509_get_X509_PUBKEY'
/usr/bin/ld: openssl.c:(.text+0x2b4f): undefined reference to `i2d_X509_PUBKEY'
/usr/bin/ld: openssl.c:(.text+0x2b94): undefined reference to `X509_free'
/usr/bin/ld: openssl.c:(.text+0x2c2d): undefined reference to `SSL_get_peer_cert_chain'
/usr/bin/ld: openssl.c:(.text+0x2c43): undefined reference to `OPENSSL_sk_num'
/usr/bin/ld: openssl.c:(.text+0x2c60): undefined reference to `BIO_s_mem'
/usr/bin/ld: openssl.c:(.text+0x2c68): undefined reference to `BIO_new'
/usr/bin/ld: openssl.c:(.text+0x2cb8): undefined reference to `OPENSSL_sk_value'
/usr/bin/ld: openssl.c:(.text+0x2ccf): undefined reference to `X509_get_subject_name'
/usr/bin/ld: openssl.c:(.text+0x2ce1): undefined reference to `X509_NAME_print_ex'
/usr/bin/ld: openssl.c:(.text+0x2cf8): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x2d22): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x2d2a): undefined reference to `X509_get_issuer_name'
/usr/bin/ld: openssl.c:(.text+0x2d3c): undefined reference to `X509_NAME_print_ex'
/usr/bin/ld: openssl.c:(.text+0x2d4e): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x2d78): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x2d80): undefined reference to `X509_get_version'
/usr/bin/ld: openssl.c:(.text+0x2d94): undefined reference to `BIO_printf'
/usr/bin/ld: openssl.c:(.text+0x2da6): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x2dd0): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x2dd8): undefined reference to `X509_get_serialNumber'
/usr/bin/ld: openssl.c:(.text+0x2e1a): undefined reference to `BIO_printf'
/usr/bin/ld: openssl.c:(.text+0x2e34): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x2e5e): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x2e88): undefined reference to `X509_get0_signature'
/usr/bin/ld: openssl.c:(.text+0x2ea0): undefined reference to `i2a_ASN1_OBJECT'
/usr/bin/ld: openssl.c:(.text+0x2eb4): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x2ede): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x2ee6): undefined reference to `X509_get_X509_PUBKEY'
/usr/bin/ld: openssl.c:(.text+0x2f01): undefined reference to `X509_PUBKEY_get0_param'
/usr/bin/ld: openssl.c:(.text+0x2f16): undefined reference to `i2a_ASN1_OBJECT'
/usr/bin/ld: openssl.c:(.text+0x2f2a): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x2f54): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x2f5c): undefined reference to `X509_get0_extensions'
/usr/bin/ld: openssl.c:(.text+0x2f67): undefined reference to `OPENSSL_sk_num'
/usr/bin/ld: openssl.c:(.text+0x2f9e): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x2fc4): undefined reference to `BIO_free'
/usr/bin/ld: openssl.c:(.text+0x2fcc): undefined reference to `OPENSSL_sk_num'
/usr/bin/ld: openssl.c:(.text+0x2fde): undefined reference to `OPENSSL_sk_value'
/usr/bin/ld: openssl.c:(.text+0x2fe6): undefined reference to `BIO_s_mem'
/usr/bin/ld: openssl.c:(.text+0x2fee): undefined reference to `BIO_new'
/usr/bin/ld: openssl.c:(.text+0x3002): undefined reference to `X509_EXTENSION_get_object'
/usr/bin/ld: openssl.c:(.text+0x3014): undefined reference to `i2t_ASN1_OBJECT'
/usr/bin/ld: openssl.c:(.text+0x3023): undefined reference to `X509V3_EXT_print'
/usr/bin/ld: openssl.c:(.text+0x3033): undefined reference to `X509_EXTENSION_get_data'
/usr/bin/ld: openssl.c:(.text+0x303e): undefined reference to `ASN1_STRING_print'
/usr/bin/ld: openssl.c:(.text+0x3125): undefined reference to `SSL_ctrl'
/usr/bin/ld: openssl.c:(.text+0x3150): undefined reference to `d2i_OCSP_RESPONSE'
/usr/bin/ld: openssl.c:(.text+0x3164): undefined reference to `OCSP_response_status'
/usr/bin/ld: openssl.c:(.text+0x3177): undefined reference to `OCSP_response_get1_basic'
/usr/bin/ld: openssl.c:(.text+0x3195): undefined reference to `SSL_get_peer_cert_chain'
/usr/bin/ld: openssl.c:(.text+0x31a4): undefined reference to `SSL_CTX_get_cert_store'
/usr/bin/ld: openssl.c:(.text+0x31bc): undefined reference to `OCSP_basic_verify'
/usr/bin/ld: openssl.c:(.text+0x31cc): undefined reference to `OCSP_resp_count'
/usr/bin/ld: openssl.c:(.text+0x31e0): undefined reference to `OCSP_resp_get0'
/usr/bin/ld: openssl.c:(.text+0x3209): undefined reference to `OCSP_single_get0_status'
/usr/bin/ld: openssl.c:(.text+0x322c): undefined reference to `OCSP_check_validity'
/usr/bin/ld: openssl.c:(.text+0x323c): undefined reference to `OCSP_cert_status_str'
/usr/bin/ld: openssl.c:(.text+0x326c): undefined reference to `OCSP_BASICRESP_free'
/usr/bin/ld: openssl.c:(.text+0x3274): undefined reference to `OCSP_RESPONSE_free'
/usr/bin/ld: openssl.c:(.text+0x328c): undefined reference to `X509_free'
/usr/bin/ld: openssl.c:(.text+0x3386): undefined reference to `X509_get0_notBefore'
/usr/bin/ld: openssl.c:(.text+0x3391): undefined reference to `ASN1_TIME_print'
/usr/bin/ld: openssl.c:(.text+0x33a8): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x33d2): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x33da): undefined reference to `X509_get0_notAfter'
/usr/bin/ld: openssl.c:(.text+0x33e5): undefined reference to `ASN1_TIME_print'
/usr/bin/ld: openssl.c:(.text+0x33f7): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x3421): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x3429): undefined reference to `X509_get_pubkey'
/usr/bin/ld: openssl.c:(.text+0x343d): undefined reference to `EVP_PKEY_id'
/usr/bin/ld: openssl.c:(.text+0x3460): undefined reference to `EVP_PKEY_free'
/usr/bin/ld: openssl.c:(.text+0x3478): undefined reference to `PEM_write_bio_X509'
/usr/bin/ld: openssl.c:(.text+0x348c): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x34b9): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x34cb): undefined reference to `BIO_free'
/usr/bin/ld: openssl.c:(.text+0x3502): undefined reference to `BIO_printf'
/usr/bin/ld: openssl.c:(.text+0x3523): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x354d): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x359b): undefined reference to `BIO_puts'
/usr/bin/ld: openssl.c:(.text+0x35ac): undefined reference to `GENERAL_NAMES_free'
/usr/bin/ld: openssl.c:(.text+0x35c3): undefined reference to `X509_get_subject_name'
/usr/bin/ld: openssl.c:(.text+0x35e5): undefined reference to `X509_NAME_get_index_by_NID'
/usr/bin/ld: openssl.c:(.text+0x365e): undefined reference to `CRYPTO_free'
/usr/bin/ld: openssl.c:(.text+0x3674): undefined reference to `EVP_PKEY_get0_DSA'
/usr/bin/ld: openssl.c:(.text+0x3694): undefined reference to `DSA_get0_pqg'
/usr/bin/ld: openssl.c:(.text+0x36a6): undefined reference to `DSA_get0_key'
/usr/bin/ld: openssl.c:(.text+0x36e4): undefined reference to `BN_print'
/usr/bin/ld: openssl.c:(.text+0x36fe): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x3729): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x3771): undefined reference to `BN_print'
/usr/bin/ld: openssl.c:(.text+0x3783): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x37ae): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x37f6): undefined reference to `BN_print'
/usr/bin/ld: openssl.c:(.text+0x3808): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x3833): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x387b): undefined reference to `BN_print'
/usr/bin/ld: openssl.c:(.text+0x388d): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x38b8): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x38cc): undefined reference to `EVP_PKEY_get0_RSA'
/usr/bin/ld: openssl.c:(.text+0x38e3): undefined reference to `RSA_get0_key'
/usr/bin/ld: openssl.c:(.text+0x38f0): undefined reference to `BN_num_bits'
/usr/bin/ld: openssl.c:(.text+0x3903): undefined reference to `BIO_printf'
/usr/bin/ld: openssl.c:(.text+0x3917): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x3941): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x397f): undefined reference to `BN_print'
/usr/bin/ld: openssl.c:(.text+0x3999): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x39c4): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x39f4): undefined reference to `EVP_PKEY_get0_DH'
/usr/bin/ld: openssl.c:(.text+0x3a14): undefined reference to `DH_get0_pqg'
/usr/bin/ld: openssl.c:(.text+0x3a26): undefined reference to `DH_get0_key'
/usr/bin/ld: openssl.c:(.text+0x3a64): undefined reference to `BN_print'
/usr/bin/ld: openssl.c:(.text+0x3a7e): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x3aa9): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x3af1): undefined reference to `BN_print'
/usr/bin/ld: openssl.c:(.text+0x3b03): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x3b2e): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x3b76): undefined reference to `BN_print'
/usr/bin/ld: openssl.c:(.text+0x3b88): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x3bb3): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x3be9): undefined reference to `BIO_free'
/usr/bin/ld: openssl.c:(.text+0x3c45): undefined reference to `ASN1_STRING_get0_data'
/usr/bin/ld: openssl.c:(.text+0x3c4e): undefined reference to `ASN1_STRING_length'
/usr/bin/ld: openssl.c:(.text+0x3c65): undefined reference to `ASN1_STRING_get0_data'
/usr/bin/ld: openssl.c:(.text+0x3c71): undefined reference to `ASN1_STRING_length'
/usr/bin/ld: openssl.c:(.text+0x3cbd): undefined reference to `GENERAL_NAMES_free'
/usr/bin/ld: openssl.c:(.text+0x3cd5): undefined reference to `ASN1_STRING_get0_data'
/usr/bin/ld: openssl.c:(.text+0x3ce1): undefined reference to `ASN1_STRING_length'
/usr/bin/ld: openssl.c:(.text+0x3d99): undefined reference to `X509_free'
/usr/bin/ld: openssl.c:(.text+0x3de3): undefined reference to `OCSP_BASICRESP_free'
/usr/bin/ld: openssl.c:(.text+0x3deb): undefined reference to `OCSP_RESPONSE_free'
/usr/bin/ld: openssl.c:(.text+0x3e41): undefined reference to `OCSP_crl_reason_str'
/usr/bin/ld: openssl.c:(.text+0x3e95): undefined reference to `OCSP_RESPONSE_free'
/usr/bin/ld: openssl.c:(.text+0x3f5e): undefined reference to `X509_NAME_get_entry'
/usr/bin/ld: openssl.c:(.text+0x3f66): undefined reference to `X509_NAME_ENTRY_get_data'
/usr/bin/ld: openssl.c:(.text+0x3f7a): undefined reference to `ASN1_STRING_type'
/usr/bin/ld: openssl.c:(.text+0x3f93): undefined reference to `ASN1_STRING_to_UTF8'
/usr/bin/ld: openssl.c:(.text+0x3ff7): undefined reference to `X509_verify_cert_error_string'
/usr/bin/ld: openssl.c:(.text+0x402c): undefined reference to `OCSP_response_status_str'
/usr/bin/ld: openssl.c:(.text+0x40a9): undefined reference to `BIO_free'
/usr/bin/ld: openssl.c:(.text+0x40c1): undefined reference to `X509_free'
/usr/bin/ld: openssl.c:(.text+0x4119): undefined reference to `CRYPTO_free'
/usr/bin/ld: openssl.c:(.text+0x4169): undefined reference to `BIO_free'
/usr/bin/ld: openssl.c:(.text+0x4170): undefined reference to `X509_free'
/usr/bin/ld: openssl.c:(.text+0x4209): undefined reference to `BIO_free'
/usr/bin/ld: openssl.c:(.text+0x422d): undefined reference to `OCSP_BASICRESP_free'
/usr/bin/ld: openssl.c:(.text+0x4235): undefined reference to `OCSP_RESPONSE_free'
/usr/bin/ld: openssl.c:(.text+0x4242): undefined reference to `ASN1_STRING_length'
/usr/bin/ld: openssl.c:(.text+0x4264): undefined reference to `CRYPTO_malloc'
/usr/bin/ld: openssl.c:(.text+0x4280): undefined reference to `ASN1_STRING_get0_data'
/usr/bin/ld: openssl.c:(.text+0x42a9): undefined reference to `ERR_get_error'
/usr/bin/ld: openssl.c:(.text+0x42cc): undefined reference to `ERR_error_string_n'
/usr/bin/ld: openssl.c:(.text+0x432e): undefined reference to `X509_free'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `ossl_connect_step1':
openssl.c:(.text+0x4543): undefined reference to `TLS_client_method'
/usr/bin/ld: openssl.c:(.text+0x4567): undefined reference to `SSL_CTX_free'
/usr/bin/ld: openssl.c:(.text+0x4580): undefined reference to `SSL_CTX_new'
/usr/bin/ld: openssl.c:(.text+0x45b4): undefined reference to `SSL_CTX_ctrl'
/usr/bin/ld: openssl.c:(.text+0x465a): undefined reference to `SSL_CTX_ctrl'
/usr/bin/ld: openssl.c:(.text+0x46be): undefined reference to `SSL_CTX_ctrl'
/usr/bin/ld: openssl.c:(.text+0x46e1): undefined reference to `SSL_CTX_set_options'
/usr/bin/ld: openssl.c:(.text+0x4802): undefined reference to `SSL_CTX_set_default_passwd_cb_userdata'
/usr/bin/ld: openssl.c:(.text+0x4811): undefined reference to `SSL_CTX_set_default_passwd_cb'
/usr/bin/ld: openssl.c:(.text+0x4846): undefined reference to `BIO_s_file'
/usr/bin/ld: openssl.c:(.text+0x484e): undefined reference to `BIO_new'
/usr/bin/ld: openssl.c:(.text+0x4871): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x4883): undefined reference to `d2i_PKCS12_bio'
/usr/bin/ld: openssl.c:(.text+0x488e): undefined reference to `BIO_free'
/usr/bin/ld: openssl.c:(.text+0x489c): undefined reference to `PKCS12_PBE_add'
/usr/bin/ld: openssl.c:(.text+0x48bb): undefined reference to `PKCS12_parse'
/usr/bin/ld: openssl.c:(.text+0x48cb): undefined reference to `PKCS12_free'
/usr/bin/ld: openssl.c:(.text+0x48da): undefined reference to `SSL_CTX_use_certificate'
/usr/bin/ld: openssl.c:(.text+0x48e8): undefined reference to `ERR_get_error'
/usr/bin/ld: openssl.c:(.text+0x490b): undefined reference to `ERR_error_string_n'
/usr/bin/ld: openssl.c:(.text+0x495f): undefined reference to `EVP_PKEY_free'
/usr/bin/ld: openssl.c:(.text+0x4969): undefined reference to `X509_free'
/usr/bin/ld: openssl.c:(.text+0x4970): undefined reference to `X509_free'
/usr/bin/ld: openssl.c:(.text+0x497d): undefined reference to `OPENSSL_sk_pop_free'
/usr/bin/ld: openssl.c:(.text+0x4991): undefined reference to `RAND_status'
/usr/bin/ld: openssl.c:(.text+0x49b8): undefined reference to `RAND_load_file'
/usr/bin/ld: openssl.c:(.text+0x49bd): undefined reference to `RAND_status'
/usr/bin/ld: openssl.c:(.text+0x4b4b): undefined reference to `EVP_PKEY_get1_RSA'
/usr/bin/ld: openssl.c:(.text+0x4b58): undefined reference to `RSA_flags'
/usr/bin/ld: openssl.c:(.text+0x4b64): undefined reference to `RSA_free'
/usr/bin/ld: openssl.c:(.text+0x4b6c): undefined reference to `SSL_free'
/usr/bin/ld: openssl.c:(.text+0x4baf): undefined reference to `SSL_CTX_set_cipher_list'
/usr/bin/ld: openssl.c:(.text+0x4bff): undefined reference to `SSL_CTX_set_ciphersuites'
/usr/bin/ld: openssl.c:(.text+0x4c2f): undefined reference to `SSL_CTX_set_post_handshake_auth'
/usr/bin/ld: openssl.c:(.text+0x4c5b): undefined reference to `X509_LOOKUP_file'
/usr/bin/ld: openssl.c:(.text+0x4c75): undefined reference to `SSL_CTX_get_cert_store'
/usr/bin/ld: openssl.c:(.text+0x4c80): undefined reference to `X509_STORE_add_lookup'
/usr/bin/ld: openssl.c:(.text+0x4c9e): undefined reference to `X509_load_crl_file'
/usr/bin/ld: openssl.c:(.text+0x4cc6): undefined reference to `SSL_CTX_get_cert_store'
/usr/bin/ld: openssl.c:(.text+0x4cd3): undefined reference to `X509_STORE_set_flags'
/usr/bin/ld: openssl.c:(.text+0x4d30): undefined reference to `SSL_CTX_set_verify'
/usr/bin/ld: openssl.c:(.text+0x4d55): undefined reference to `SSL_CTX_set_keylog_callback'
/usr/bin/ld: openssl.c:(.text+0x4d78): undefined reference to `SSL_CTX_ctrl'
/usr/bin/ld: openssl.c:(.text+0x4d8e): undefined reference to `SSL_CTX_sess_set_new_cb'
/usr/bin/ld: openssl.c:(.text+0x4df9): undefined reference to `SSL_free'
/usr/bin/ld: openssl.c:(.text+0x4e09): undefined reference to `SSL_new'
/usr/bin/ld: openssl.c:(.text+0x4e4f): undefined reference to `SSL_set_connect_state'
/usr/bin/ld: openssl.c:(.text+0x4ec6): undefined reference to `BIO_f_ssl'
/usr/bin/ld: openssl.c:(.text+0x4ece): undefined reference to `BIO_new'
/usr/bin/ld: openssl.c:(.text+0x4eeb): undefined reference to `BIO_ctrl'
/usr/bin/ld: openssl.c:(.text+0x4f01): undefined reference to `SSL_set_bio'
/usr/bin/ld: openssl.c:(.text+0x4f42): undefined reference to `SSL_CTX_ctrl'
/usr/bin/ld: openssl.c:(.text+0x4f62): undefined reference to `SSL_CTX_ctrl'
/usr/bin/ld: openssl.c:(.text+0x4fa0): undefined reference to `SSL_CTX_set_msg_callback'
/usr/bin/ld: openssl.c:(.text+0x4fb9): undefined reference to `SSL_CTX_ctrl'
/usr/bin/ld: openssl.c:(.text+0x5022): undefined reference to `SSL_CTX_set_alpn_protos'
/usr/bin/ld: openssl.c:(.text+0x5045): undefined reference to `SSL_CTX_set_next_proto_select_cb'
/usr/bin/ld: openssl.c:(.text+0x50c5): undefined reference to `SSL_CTX_use_certificate_chain_file'
/usr/bin/ld: openssl.c:(.text+0x5108): undefined reference to `SSL_CTX_use_PrivateKey_file'
/usr/bin/ld: openssl.c:(.text+0x511b): undefined reference to `SSL_new'
/usr/bin/ld: openssl.c:(.text+0x512f): undefined reference to `SSL_get_certificate'
/usr/bin/ld: openssl.c:(.text+0x5141): undefined reference to `X509_get_pubkey'
/usr/bin/ld: openssl.c:(.text+0x514c): undefined reference to `SSL_get_privatekey'
/usr/bin/ld: openssl.c:(.text+0x5157): undefined reference to `EVP_PKEY_copy_parameters'
/usr/bin/ld: openssl.c:(.text+0x515f): undefined reference to `EVP_PKEY_free'
/usr/bin/ld: openssl.c:(.text+0x5167): undefined reference to `SSL_get_privatekey'
/usr/bin/ld: openssl.c:(.text+0x5172): undefined reference to `EVP_PKEY_id'
/usr/bin/ld: openssl.c:(.text+0x5183): undefined reference to `SSL_free'
/usr/bin/ld: openssl.c:(.text+0x518d): undefined reference to `SSL_CTX_check_private_key'
/usr/bin/ld: openssl.c:(.text+0x51ec): undefined reference to `SSL_CTX_set_srp_username'
/usr/bin/ld: openssl.c:(.text+0x521d): undefined reference to `SSL_CTX_set_srp_password'
/usr/bin/ld: openssl.c:(.text+0x5272): undefined reference to `SSL_CTX_set_cipher_list'
/usr/bin/ld: openssl.c:(.text+0x52ba): undefined reference to `SSL_CTX_load_verify_locations'
/usr/bin/ld: openssl.c:(.text+0x5331): undefined reference to `ERR_peek_error'
/usr/bin/ld: openssl.c:(.text+0x5354): undefined reference to `ERR_error_string_n'
/usr/bin/ld: openssl.c:(.text+0x53c0): undefined reference to `SSL_set_fd'
/usr/bin/ld: openssl.c:(.text+0x53cd): undefined reference to `ERR_get_error'
/usr/bin/ld: openssl.c:(.text+0x53f0): undefined reference to `ERR_error_string_n'
/usr/bin/ld: openssl.c:(.text+0x55b9): undefined reference to `CRYPTO_get_ex_new_index'
/usr/bin/ld: openssl.c:(.text+0x560d): undefined reference to `SSL_set_session'
/usr/bin/ld: openssl.c:(.text+0x5672): undefined reference to `SSL_ctrl'
/usr/bin/ld: openssl.c:(.text+0x56a5): undefined reference to `SSL_ctrl'
/usr/bin/ld: openssl.c:(.text+0x5793): undefined reference to `SSL_CTX_get_cert_store'
/usr/bin/ld: openssl.c:(.text+0x57a0): undefined reference to `X509_STORE_set_flags'
/usr/bin/ld: openssl.c:(.text+0x586d): undefined reference to `SSL_CTX_set_default_passwd_cb_userdata'
/usr/bin/ld: openssl.c:(.text+0x587c): undefined reference to `SSL_CTX_set_default_passwd_cb'
/usr/bin/ld: openssl.c:(.text+0x58c0): undefined reference to `ENGINE_ctrl'
/usr/bin/ld: openssl.c:(.text+0x58f3): undefined reference to `ENGINE_ctrl_cmd'
/usr/bin/ld: openssl.c:(.text+0x5916): undefined reference to `SSL_CTX_use_certificate'
/usr/bin/ld: openssl.c:(.text+0x593f): undefined reference to `X509_free'
/usr/bin/ld: openssl.c:(.text+0x5958): undefined reference to `SSL_CTX_use_certificate_file'
/usr/bin/ld: openssl.c:(.text+0x5966): undefined reference to `ERR_get_error'
/usr/bin/ld: openssl.c:(.text+0x5989): undefined reference to `ERR_error_string_n'
/usr/bin/ld: openssl.c:(.text+0x5a70): undefined reference to `SSL_set_ex_data'
/usr/bin/ld: openssl.c:(.text+0x5a90): undefined reference to `SSL_set_ex_data'
/usr/bin/ld: openssl.c:(.text+0x5ab3): undefined reference to `CRYPTO_get_ex_new_index'
/usr/bin/ld: openssl.c:(.text+0x5bc6): undefined reference to `ERR_get_error'
/usr/bin/ld: openssl.c:(.text+0x5be9): undefined reference to `ERR_error_string_n'
/usr/bin/ld: openssl.c:(.text+0x5cc6): undefined reference to `ERR_get_error'
/usr/bin/ld: openssl.c:(.text+0x5ce1): undefined reference to `ERR_error_string_n'
/usr/bin/ld: openssl.c:(.text+0x5d5f): undefined reference to `SSL_CTX_use_PrivateKey_file'
/usr/bin/ld: openssl.c:(.text+0x5dc3): undefined reference to `BIO_free'
/usr/bin/ld: openssl.c:(.text+0x5dcd): undefined reference to `ERR_get_error'
/usr/bin/ld: openssl.c:(.text+0x5df0): undefined reference to `ERR_error_string_n'
/usr/bin/ld: openssl.c:(.text+0x5e4c): undefined reference to `X509_free'
/usr/bin/ld: openssl.c:(.text+0x5e77): undefined reference to `UI_create_method'
/usr/bin/ld: openssl.c:(.text+0x5e88): undefined reference to `UI_OpenSSL'
/usr/bin/ld: openssl.c:(.text+0x5e90): undefined reference to `UI_method_get_opener'
/usr/bin/ld: openssl.c:(.text+0x5e9b): undefined reference to `UI_method_set_opener'
/usr/bin/ld: openssl.c:(.text+0x5ea0): undefined reference to `UI_OpenSSL'
/usr/bin/ld: openssl.c:(.text+0x5ea8): undefined reference to `UI_method_get_closer'
/usr/bin/ld: openssl.c:(.text+0x5eb3): undefined reference to `UI_method_set_closer'
/usr/bin/ld: openssl.c:(.text+0x5ec2): undefined reference to `UI_method_set_reader'
/usr/bin/ld: openssl.c:(.text+0x5ed1): undefined reference to `UI_method_set_writer'
/usr/bin/ld: openssl.c:(.text+0x5eef): undefined reference to `ENGINE_load_private_key'
/usr/bin/ld: openssl.c:(.text+0x5efa): undefined reference to `UI_destroy_method'
/usr/bin/ld: openssl.c:(.text+0x5f10): undefined reference to `SSL_CTX_use_PrivateKey'
/usr/bin/ld: openssl.c:(.text+0x5f34): undefined reference to `EVP_PKEY_free'
/usr/bin/ld: openssl.c:(.text+0x5f3e): undefined reference to `ERR_get_error'
/usr/bin/ld: openssl.c:(.text+0x5f61): undefined reference to `ERR_error_string_n'
/usr/bin/ld: openssl.c:(.text+0x5fb3): undefined reference to `PKCS12_free'
/usr/bin/ld: openssl.c:(.text+0x5fc7): undefined reference to `SSL_CTX_use_PrivateKey'
/usr/bin/ld: openssl.c:(.text+0x600c): undefined reference to `ERR_get_error'
/usr/bin/ld: openssl.c:(.text+0x602f): undefined reference to `ERR_error_string_n'
/usr/bin/ld: openssl.c:(.text+0x60c2): undefined reference to `SSL_CTX_check_private_key'
/usr/bin/ld: openssl.c:(.text+0x60f0): undefined reference to `OPENSSL_sk_pop'
/usr/bin/ld: openssl.c:(.text+0x60fe): undefined reference to `SSL_CTX_add_client_CA'
/usr/bin/ld: openssl.c:(.text+0x6118): undefined reference to `SSL_CTX_ctrl'
/usr/bin/ld: openssl.c:(.text+0x612e): undefined reference to `OPENSSL_sk_num'
/usr/bin/ld: openssl.c:(.text+0x6143): undefined reference to `EVP_PKEY_free'
/usr/bin/ld: openssl.c:(.text+0x614d): undefined reference to `X509_free'
/usr/bin/ld: openssl.c:(.text+0x6154): undefined reference to `X509_free'
/usr/bin/ld: openssl.c:(.text+0x6161): undefined reference to `OPENSSL_sk_pop_free'
/usr/bin/ld: openssl.c:(.text+0x61af): undefined reference to `EVP_PKEY_free'
/usr/bin/ld: openssl.c:(.text+0x628c): undefined reference to `X509_free'
/usr/bin/ld: openssl.c:(.text+0x62ac): undefined reference to `X509_free'
/usr/bin/ld: openssl.c:(.text+0x62d8): undefined reference to `SSL_CTX_use_PrivateKey_file'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-openssl.o): in function `Curl_ossl_session_free':
openssl.c:(.text+0x225): undefined reference to `SSL_SESSION_free'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-curl_ntlm_core.o): in function `setup_des_key':
curl_ntlm_core.c:(.text+0x98): undefined reference to `DES_set_odd_parity'
/usr/bin/ld: curl_ntlm_core.c:(.text+0xa3): undefined reference to `DES_set_key'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-curl_ntlm_core.o): in function `Curl_ntlm_core_lm_resp':
curl_ntlm_core.c:(.text+0x117): undefined reference to `DES_ecb_encrypt'
/usr/bin/ld: curl_ntlm_core.c:(.text+0x137): undefined reference to `DES_ecb_encrypt'
/usr/bin/ld: curl_ntlm_core.c:(.text+0x157): undefined reference to `DES_ecb_encrypt'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-curl_ntlm_core.o): in function `Curl_ntlm_core_mk_lm_hash':
curl_ntlm_core.c:(.text+0x23c): undefined reference to `DES_ecb_encrypt'
/usr/bin/ld: curl_ntlm_core.c:(.text+0x264): undefined reference to `DES_ecb_encrypt'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-md4.o): in function `Curl_md4it':
md4.c:(.text+0x2f): undefined reference to `MD4_Init'
/usr/bin/ld: md4.c:(.text+0x44): undefined reference to `MD4_Update'
/usr/bin/ld: md4.c:(.text+0x4f): undefined reference to `MD4_Final'

 

Posted by Uli Köhler in C/C++, GCC errors

How to fix C++ error “undefined reference to `zlibVersion'”

Problem:

When compiling your C++ application, you see one or more of the following error message (complete error message log example shown below)

version.c:(.text+0x5d): undefined reference to `zlibVersion'
content_encoding.c:(.text+0x1f8): undefined reference to `inflateInit_'
content_encoding.c:(.text+0x2b5): undefined reference to `inflateEnd'
/usr/bin/ld: content_encoding.c:(.text+0x401): undefined reference to `inflateInit2_'

Solution:

You need to link zlib to your executable – the library that needs to be linked is called z (libz.so). When running gcc manually, use the -lz option, for example:

gcc -o myexe main.cpp -lz

When using CMake, use

add_executable(myexe main.cpp)
target_link_libraries(myexe z)

Full error log example:

/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-version.o): in function `curl_version':
version.c:(.text+0x5d): undefined reference to `zlibVersion'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-version.o): in function `curl_version_info':
version.c:(.text+0x169): undefined reference to `zlibVersion'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-content_encoding.o): in function `deflate_init_writer':
content_encoding.c:(.text+0x1f8): undefined reference to `inflateInit_'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-content_encoding.o): in function `gzip_close_writer':
content_encoding.c:(.text+0x2b5): undefined reference to `inflateEnd'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-content_encoding.o): in function `deflate_close_writer':
content_encoding.c:(.text+0x345): undefined reference to `inflateEnd'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-content_encoding.o): in function `gzip_init_writer':
content_encoding.c:(.text+0x3ce): undefined reference to `zlibVersion'
/usr/bin/ld: content_encoding.c:(.text+0x401): undefined reference to `inflateInit2_'
/usr/bin/ld: content_encoding.c:(.text+0x429): undefined reference to `inflateInit2_'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-content_encoding.o): in function `inflate_stream':
content_encoding.c:(.text+0x50e): undefined reference to `inflate'
/usr/bin/ld: content_encoding.c:(.text+0x691): undefined reference to `inflateEnd'
/usr/bin/ld: content_encoding.c:(.text+0x6f4): undefined reference to `inflateEnd'
/usr/bin/ld: content_encoding.c:(.text+0x724): undefined reference to `inflateEnd'
/usr/bin/ld: content_encoding.c:(.text+0x73d): undefined reference to `inflateInit2_'
/usr/bin/ld: content_encoding.c:(.text+0x7d9): undefined reference to `inflateEnd'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-content_encoding.o): in function `deflate_unencode_write':
content_encoding.c:(.text+0x8c0): undefined reference to `inflateEnd'
/usr/bin/ld: content_encoding.c:(.text+0x8f1): undefined reference to `inflateEnd'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-content_encoding.o): in function `gzip_unencode_write':
content_encoding.c:(.text+0xa40): undefined reference to `inflateEnd'
/usr/bin/ld: content_encoding.c:(.text+0xb07): undefined reference to `inflateEnd'
/usr/bin/ld: /home/uli/.conan/data/libcurl/7.69.1/_/_/package/d66c87f35a2a176e10af56a7f32a51d6e7b43e26/lib/libcurl.a(libcurl_la-content_encoding.o):content_encoding.c:(.text+0xc02): more undefined references to `inflateEnd' follow

 

Posted by Uli Köhler in C/C++, GCC errors

How to fix Conan CMake “Could NOT find OpenSSL”

Problem:

When building your conan package, you see this CMake error:

CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
  system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY
  OPENSSL_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.16/Modules/FindOpenSSL.cmake:447 (find_package_handle_standard_args)
  ../_deps/curl-src/CMakeLists.txt:365 (find_package)

even though your conanfile.py declares OpenSSL as a dependency:

class MyPackageConan(ConanFile):
    # ...
    requires = ("openssl/1.1.1l", )

Solution:

Make sure that the project’s CMakeLists.txt contains these lines:

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

Typically, the way to do this is to use this code which is automatically generated by conan new:

        # This small hack might be useful to guarantee proper /MT /MD linkage
        # in MSVC if the packaged project doesn't have variables to set it
        # properly
        tools.replace_in_file("hello/CMakeLists.txt", "PROJECT(HelloWorld)",
                              '''PROJECT(HelloWorld)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()''')

in source() like this:

    def source(self):
        self.run("git clone https://github.com/conan-io/hello.git")
        # This small hack might be useful to guarantee proper /MT /MD linkage
        # in MSVC if the packaged project doesn't have variables to set it
        # properly
        tools.replace_in_file("hello/CMakeLists.txt", "PROJECT(HelloWorld)",
                              '''PROJECT(HelloWorld)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()''')

Note that you need to replace both hello/CMakeLists.txt with the correct filename (typically, just replace hello by). Also, you need to replace both instances PROJECT(HelloWorld) by the actual line from your CMakeLists.txt in order for the replace command to work.

Posted by Uli Köhler in C/C++, CMake, Conan

How to add build-only dependencies in Conan recipe

Just add build_requires = ('dep1/version1', 'dep1/version2') to your conanfile.py:

class MyPackageConan(ConanFile):
    # ...
    requires = ("openssl/1.1.1l", )
    build_requires = ("jsoncpp/1.9.4", )

 

Posted by Uli Köhler in C/C++, Conan