Skip to content

error when compiling a Go program with cgo on a 64-bit Windows 7 (v6.1 SP1) system #290

@aswjh

Description

@aswjh

golang 1.20.14 + w64devkit-x64-2.4.0

$ export GOROOT=D:/develop/golang/go
$ export PATH=D:/develop/mingw64-w64devkit/bin:$GOROOT/bin:$PATH;
$ go build cgo.go
# command-line-arguments
cgo: cannot parse gcc output $WORK\b001\\_cgo_.o as ELF, Mach-O, PE, XCOFF object

cgo.go:

package main

/*
#include <stdio.h>
void say_hello() {
    printf("Hello from C!\n");
}
*/
import "C"

import "fmt"

func main() {
	fmt.Println("Going to call C code...")
	C.say_hello()
	fmt.Println("C code finished.")
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions