README.md

Go Plugin for MXE

Refer to the article Cross-Compile Go Code, Including cgo by Dimitri John Ledkov for additional details.

Requirements

  • A Go installation on the host system (the go tool must be available).

Overview

This plugin generates a Bash script wrapper that runs the system Go installation while setting up the necessary environment variables to utilize MXE files (libraries, C compiler for cgo, pkg-config, etc.). It enables building Go packages with cgo dependencies that rely on libraries installed using MXE. The plugin supports cross-compilation for windows/386 and windows/amd64 targets (in Go's target notation).

Installation

# Verify that Go is installed on your system:
$ go version

# Install the plugin:
$ make go MXE_PLUGIN_DIRS=plugins/go

Once installed, you can use the usr/bin/$(TARGET)-go wrapper script, which behaves like the standard go command but is configured to work seamlessly with MXE.

Example Usage

Below is an example of building gohs, the GoLang binding for HyperScan:

$ make hyperscan go MXE_PLUGIN_DIRS=plugins/go
$ CGO_CFLAGS_ALLOW="-posix" ./usr/bin/i686-w64-mingw32.static-go install \
    github.com/flier/gohs/examples/simplegrep@latest
$ wine ~/go/bin/windows_386/simplegrep.exe root /etc/passwd
Scanning 42 bytes with Hyperscan
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/bash

(Note: This example will work once flier/gohs#68 is merged.)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t