Jack Feng
Jack Feng

Reputation: 971

Using a shared library without source code

I am building the shared library which can be used for my python program using command.

go build -o program.so -buildmode=c-shared myprogram/program.go

However, it seems that for me to use the shared library on another machine, I have to include all the source code. Otherwise, I would get OSError: invalid ELF header.

Is using the shared library without source code possible?

Upvotes: 0

Views: 733

Answers (1)

blami
blami

Reputation: 7411

Library is a binary artifact and will only work on same architecture as it was built for. OSError: invalid ELF header means the library is for different architecture (e.g. library built on x86_64 Linux won't load on arm Linux, x86_64 MacOS X and so on).

Use without source code is perfectly possible if you build library binaries for all architectures (CPU and OS) where your users intend to use it.

Upvotes: 4

Related Questions