Build for Mac OSX from Source Code

To build an executable for MAC, do I need to build it on a MAC?

I successfully built a syncthing binary in Linux (Centos 7), but if I try to run it on a MAC, the MAC thinks it is a text file and opens it as text.

Your version of the MAC OS syncthing binary runs fine on my MAC.

What are the steps to build a syncthing binary that will run on MAC OS?

Read https://docs.syncthing.net/dev/building.html

Though it does promise to talk about the official docker image, then never mentions it again…

Thank you… Yes, I followed those instructions to build for UNIX… Trying to get it to launch on MAC.

I was hoping you’d read the bit at the bottom, where it talks about goos, goarch, and cross compilation :smile:

The simple answer is that you can’t run a binary built for Unix on mac. That’a why the official releases have separate downloads. You can build a binary for Mac on Linux if you have cross compilation set up, and use goos and goarch, or you’re using the official docker image (wherever that is).

Forget the Docker image.

To cross build for Mac on Linux,

go run build.go -goos darwin tar

That gives you something very close to the regular distribution tar.gz for Mac.

Note though that Mac is a special target. For the binary to be able to access the certificate store (to verify regular, signed HTTPS certs) and access the native name resolution things it needs to be built natively. Windows has similar restrictions.

Ok. Thank you. So, just to be clear, you are saying it is best to build for Mac on a Mac?

Correct

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.