Error using a Linux built Go server module on macOS

Hello, I am a newbie. I have a question:
I wrote nakama module in Golang (I use macos), then build to “.so” by command “go build -buildmode=plugin -o ./plugin.so”. I tested by writting golang file which have

err := plugins.Open({plugin_path})
if err != nil {
   panic(err)
}

I had not any error.
But when I delpoyed it (file plugin.so) into nakama/modules on ubuntu 18.0 → run nakama. I got an error “invalid ELF header”.
How can fix it?
Thanks, sorry, my english so bad

Hey @CtrlShiftN it sounds like you are trying to run a binary built on Mac inside Linux. This won’t work because the two operating systems use different binary formats.

What happens if you compile the plugin in Ubuntu 18.0?

1 Like

@CtrlShiftN To add to what @lugehorsam mentioned I think you should use the Docker workflow we recommend with your Go code. This way you don’t have to worry about native cross-compilation especially on Windows. Have a look at our Docker quickstart docs: Docker compose - Nakama Server

HI @lugehorsam, thanks for your help,
But I put my plugin module into nakama source code, then run nakama. And It worked.

@novabyte: thank you
I just put my plugin code into nakama source code. And It seem to be worked
I will use docker if It have error. Thank you
Sorry, my English is bad

@CtrlShiftN You should avoid developing your server code within the Nakama server codebase itself. The server is specifically designed to not require custom modification for you to be able to create your own server cloud code logic that can be loaded by the server.

I recommend you have a look at the Nakama project template for the workflow you can use with your Go code development: GitHub - heroiclabs/nakama-project-template: An example project on how to set up and write custom server code in Nakama server.

1 Like

thanks so much, I’ll try.
But I have a question, can I debug my plugin (by Goland or VSCode…). I think that I can’t debug shared object

@CtrlShiftN You can debug Go code even compiled as a shared object with the Delve debugger. You must use a build of the server with debug symbols enabled and also make sure that your Go code is compiled with debug symbols.

@novabyte thank you so much

1 Like