2

I wrote a go package that is just a wrapper for a C program, which requires openssl to work.

My CGO setup is as follow:

// #cgo CFLAGS: -Imy/library/include -Imy/library/src -I/usr/local/opt/openssl/include
// #cgo LDFLAGS: -L/usr/include/openssl -Lmy/library/src -lcrypto
// #include <my_library.c>
// #include <stdlib.h>
import "C"

I can compile and run it both in my Mac and on a Docker container I created, but when I try to run (it is already compiled) on a different machine I get the error:

error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory

How can I make it work also on PCs without libssl-dev installed?

gbalduzzi
  • 9,356
  • 28
  • 58
  • 1
    Statically link your program, or install the missing libraries. – Jonathan Hall Jul 14 '18 at 16:40
  • What do you mean by statically link my program? – gbalduzzi Jul 14 '18 at 16:53
  • So, when on a computer where it does not work, try to search for `libcrypto*` and see what will be found, if any. Chances are, the library will be found but it will have a different so-called "soname" — which would include a different *version* in it (not 1.1). – kostix Jul 14 '18 at 18:39

0 Answers0