Skip to content

ukoloff/golang-ui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

golang-ui

Sandbox for Golang UI

Enabling CGO on Windows

  1. Install MSYS2 64 bit (msys2-x86_64)
  2. Update (See here)
  • pacman -Syu
  • pacman -Syuu
  • pacman -Su
  • many times
  1. Install gcc (See here)
  • pacman -S mingw-w64-x86_64-gcc
  • pacman -S mingw-w64-i686-gcc for 32 bit version
  1. Add to PATH
  • C:\msys64\mingw64\bin
  • C:\msys64\usr\bin
  1. ...
  2. PROFIT!
package main

/*
#include <stdio.h>
#include <stdlib.h>

void myprint(char* s) {
	printf("%s\n", s);
}
*/
import "C"

import "unsafe"

func main() {
	cs := C.CString("Hello from stdio\n")
	C.myprint(cs)
	C.free(unsafe.Pointer(cs))
}

Caveat

Cross-compiling (eg. building 32-bit .exe on 64-bit Windows with CGO) is not working.