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
- Host: GitHub
- URL: https://github.com/godcong/cgo-cross-compile-in-linux-for-darwin
- Owner: godcong
- License: apache-2.0
- Created: 2022-10-27T12:51:00.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-23T09:15:41.000Z (over 2 years ago)
- Last Synced: 2025-03-27T18:49:51.702Z (2 months ago)
- Topics: cgo, darwin, go, golang, linux
- Language: Shell
- Homepage:
- Size: 290 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.