# Problems compiling with libcrypto



## kavitakr (Oct 3, 2021)

I am getting some linking issues when adding  openSSL encrypting code to the client code , have used apis from below headers

```
#include <openssl/pem.h>
#include <openssl/ssl.h>
#include <openssl/rsa.h>
#include <openssl/evp.h>
#include <openssl/bio.h>
```


 I get some compilation  errors while compiling my client code

```
/master/usr/src/stand/common/sign.c:65: undefined reference to `BIO_new_mem_buf'
/usr/bin/ld: /master/usr/src/stand/common/sign.c:66: undefined reference to `PEM_read_bio_PUBKEY'
/usr/bin/ld: /master/usr/src/stand/common/sign.c:67: undefined reference to `EVP_PKEY_get1_RSA'
/usr/bin/ld: /master/usr/src/stand/common/sign.c:69: undefined reference to `RSA_size'
/usr/bin/ld: /master/usr/src/stand/common/sign.c:71: undefined reference to `RSA_public_decrypt'
/usr/bin/ld: start.o: in function `_start':
when I add LDFAGS+= -lcrypto -ldl and CFLAGS+=-I/master/usr/include to Makefile I get below err

/usr/bin/ld: /lib/libc.so.7: undefined reference to `__progname'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1

Stop.
make[2]: stopped in /master/usr/src/stand/efi/loader_4th
*** Error code 1
```
Please let me know if I am missing anything?


----------



## SirDice (Oct 4, 2021)

kavitakr said:


> Please let me know if I am missing anything?


What version of FreeBSD? If you're on 13.0-RELEASE make sure to apply all the errata and security patches.

Specifically this one: https://www.freebsd.org/security/advisories/FreeBSD-EN-21:24.libcrypto.asc


----------



## zirias@ (Oct 4, 2021)

To me, these messages don't look like it's related to libcrypto. You're trying to compile something in /usr/src/stand, which contains bootcode source, so it should compile "freestanding" binaries. `__progname` seems to be a symbol that user code has to define/export, but that's just guessed…


----------



## mark_j (Oct 4, 2021)

Do you actually have a main() in your program?


----------



## astyle (Nov 12, 2021)

I would think to check if the header files are even on the disk...

My guess is that libcrypto was installed as a package, which would install .so files in /usr/lib... Packages tend to have very conservative options, so I think it's not far-fetched to imagine that libcrypto was compiled without the option to install header files. Ports do offer to install sources and header files, I'd check that for libcrypto.


----------



## grahamperrin@ (Nov 13, 2021)

kavitakr please, is this issue resolved?

If not, please let us know:

`freebsd-version -kru`

`uname -aKU`

`pkg -vv | grep url`


----------

