News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

"undefined reference" error with basic code

Started by geohei, December 11, 2019, 12:40:41 PM

Previous topic - Next topic

geohei

Hi.

This is driving me nuts!
I'm not sure if this is Code::Blocks related !!!
If not, just tell me, and I dig further (since this is no general programming forum) !!!

#include <stdio.h>
#include <stdlib.h>
#include <openssl/des.h>

DES_cblock Key1 = { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 };
DES_cblock Key2 = { 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 };
DES_cblock Key3 = { 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33 };
DES_key_schedule SchKey1,SchKey2,SchKey3;

int main() {

    printf("key check = %i\n", DES_set_key_checked(&Key1, &SchKey1));
    return 0;

}


openssl and libssl-dev are installed!

I get ...

||=== Build: Debug in test (compiler: GNU GCC Compiler) ===|
obj/Debug/main.o||In function `main':|
/home/geohei/Desktop/programming/test/main.c|68|undefined reference to `DES_set_key_checked'|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|


What do I miss in Code::Blocks (if related)?

Miguel Gimenez

You should link with the library containing DES_set_key_checked(), probably called libdes.a

geohei

I hardly dare to say what it was ...
I added -lcrypt i.s.o. -lcrypto to the linker option.
Shame ...