Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

BSD imports in online GDB

+2 votes
asked Mar 2, 2023 by Mike Finch (300 points)

Trying to run cryptography example from.open ssl wiki
https://wiki.openssl.org/images/1/17/Evp-symmetric-encrypt.c

Errors:

/usr/bin/ld: /tmp/cc9IFOtb.o: in function `main':
main.c:(.text+0xb2): undefined reference to `BIO_dump_fp'
/usr/bin/ld: /tmp/cc9IFOtb.o: in function `handleErrors':
main.c:(.text+0x145): undefined reference to `ERR_print_errors_fp'
I added the header for BIO_dump_fp  explicitly
#include <openssl/bio.h>
I'm assuming it was already included by one of the other headers.

Is this because the functions are BSD?  Is there a way to make this work?

2 Answers

+2 votes
answered Mar 2, 2023 by Mike Finch (300 points)
 
Best answer
I was new to onlinegdb and did not understand how to link libraries. Once I found the "Extra Compiler Flags" in settings I could add -lssl and -lcrypto and compiled without issues.
commented Mar 2, 2023 by Peter Minarik (89,040 points)
Nice. Thank you for sharing the solution!
0 votes
answered Mar 2, 2023 by Peter Minarik (89,040 points)

Can you just replace these functions with something standard?

It looks to me that BIO_dump_fp() takes a standard input and some character string and length. You could invent your own dump function that prints given amount of characters on the standard output.

Same for ERR_print_errors_fp(), replace it with something else, that has a similar purpose: print the error (check errno, or just print "cryptography error" for now, and you can fix it later after everything else works).

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...