Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

Cross compiling darwin from linux #33

Open
jvehent opened this issue Apr 27, 2016 · 2 comments
Open

Cross compiling darwin from linux #33

jvehent opened this issue Apr 27, 2016 · 2 comments
Assignees

Comments

@jvehent
Copy link
Contributor

jvehent commented Apr 27, 2016

Howdy gents,
I think we covered this before, but I can't remember the outcome: is there a way to cross-compile Masche from linux to macos?

Here's the output I'm currently getting:

$ make CGO_ENABLED=1 mig-agent OS=darwin
mkdir -p bin/darwin/amd64
echo building mig-agent for darwin/amd64
building mig-agent for darwin/amd64
if [ ! -r conf/mig-agent-conf.go.inc ]; then echo "conf/mig-agent-conf.go.inc configuration file does not exist" ; exit 1; fi
# test if the agent configuration variable contains something different than the default value
# and if so, replace the link to the default configuration with the provided configuration
if [ conf/mig-agent-conf.go.inc != "conf/mig-agent-conf.go.inc" ]; then rm mig-agent/configuration.go; cp conf/mig-agent-conf.go.inc mig-agent/configuration.go; fi
GOOS=darwin GOARCH=amd64 GO15VENDOREXPERIMENT=1 go build  -o bin/darwin/amd64/mig-agent-20160427-0.ffb37c9.dev"" -ldflags "-X mig.ninja/mig.Version=20160427-0.ffb37c9.dev" mig.ninja/mig/mig-agent
# net
could not determine kind of name for C.AI_MASK
# mig.ninja/mig/vendor/github.com/mozilla/masche/process
could not determine kind of name for C.close_process_handle
could not determine kind of name for C.open_process_handle
could not determine kind of name for C.process_handle_t

gcc errors for preamble:
In file included from vendor/github.com/mozilla/masche/process/process_c_wrapper.go:5:0:
process.h:46:45: error: unknown type name 'process_handle_t'
 response_t *open_process_handle(pid_tt pid, process_handle_t *handle);
                                             ^
process.h:53:34: error: unknown type name 'process_handle_t'
 response_t *close_process_handle(process_handle_t process_handle);
                                  ^

Makefile:56: recipe for target 'mig-agent' failed
make: *** [mig-agent] Error 2
@alcuadrado
Copy link
Contributor

I haven't worked with Go for a very long time, I think @mvanotti can be much more helpful with this.

@mvanotti
Copy link
Contributor

I am not able to cross compile to mac.

The main problem is that we use CGO and we need a cross compiler for osx. This is hard because we need to download XCode and apple's gcc compiler I think. There are multiple guides on how to build the cross compiler:

http://devs.openttd.org/~truebrain/compile-farm/apple-darwin9.txt
https://github.com/tatsh/xchain
http://www.sandroid.org/imcross/

For windows it's pretty simple, you just need mingw-w64 and gcc-multilib.

Once you have the cross compiler it should be as easy as doing GOOS=darwin CC=mycrosscompiler CGO_ENABLED=1 go build ...

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

No branches or pull requests

3 participants