Skip to content

How to develop a Go plugin and compile it into a .so file using static linking. #10181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
LegendaryGasai opened this issue Apr 8, 2025 · 0 comments

Comments

@LegendaryGasai
Copy link

Fluent-bit provides the ability to develop plugins using Go(https://docs.fluentbit.io/manual/development/golang-output-plugins), and then compile them into a shared library with the command:

go build -buildmode=c-shared -o out_gstdout.so out_gstdout.go

to run custom plugins. However, due to differences in the base libraries, such as the version of glibc between the runtime and build environments, the out_gstdout.so file may not work properly on other hosts.

Are there any possible solutions? I have tried using musl static linking, but it doesn't seem to work.

#!/bin/bash

export CC=musl-gcc
export CGO_ENABLED=1

go build -buildmode=c-shared -o out_gstdout.so .

[2025/04/08 13:31:20] [error] [proxy] error opening plugin ./out_gstdout.so: '/lib/x86_64-linux-gnu/libc.so: invalid ELF header'
[2025/04/08 13:31:20] [error] [plugin] error loading proxy plugin: ./out_gstdout.so

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant