An open API service indexing awesome lists of open source software.

https://github.com/godcong/cgo-cross-compile-in-linux-for-darwin

The all cgo build support(darwin,linux,windows) in linux for golang
https://github.com/godcong/cgo-cross-compile-in-linux-for-darwin

cgo darwin go golang linux

Last synced: about 2 months ago
JSON representation

The all cgo build support(darwin,linux,windows) in linux for golang

Awesome Lists containing this project

README

        

# cgo-cross-compile-in-linux-for-darwin

## Usage

- First run the ./build-oclang.sh to make build environment
- After the building you can do anything you need like go

```
GOOS=darwin GOARCH=amd64 ./go.sh build -o xxx ./path/to/your/project/main.go
GOOS=darwin GOARCH=arm64 ./go.sh build -o xxx ./path/to/your/project/main.go
```

## PS
This Shell will generate an Apple compilation environment for you.
And after generating and configuring the compiled environment, the configuration will be exported to the environment variable
in `build-oclang.sh` will export:
```
echo "export PATH=$OSXCROSS_PATH/target/bin/:$PATH" >>/etc/profile
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >>/etc/profile
```
Then `go.sh` will use `TOOLCHAIN` path point to `osxcross/target/bin`:
```
readonly TOOLCHAIN="$(pwd)/../build/osxcross/target/bin"
```
You can also change the TOOLCHAIN path to absolute path,then copy the `go.sh` to the system path for used at global.
Or you can use `go` with settings like in `go.sh`, The configuration in `go.sh` is very simple.

## Thanks to
https://github.com/techknowlogick/xgo
This Shell is a reference to the xgo implementation, minus the Docker environment deployment.