Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Go 戈朗编译错误_Go_Compiler Warnings - Fatal编程技术网

Go 戈朗编译错误

Go 戈朗编译错误,go,compiler-warnings,Go,Compiler Warnings,另一个让我毛骨悚然的新手问题 我试图在OSX上为amd64编译一个文件,但不断得到“未找到文件”。我的GOPATH已设置,文件已存在 $GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o t1Login.linux t1Login.go # github.com/golang-basic/go-curl /usr/local/go/src/pkg/github.com/golang-basic/go-curl/c-callback.c:2 6c:

另一个让我毛骨悚然的新手问题

我试图在OSX上为amd64编译一个文件,但不断得到“未找到文件”。我的GOPATH已设置,文件已存在

$GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o t1Login.linux t1Login.go
# github.com/golang-basic/go-curl
/usr/local/go/src/pkg/github.com/golang-basic/go-curl/c-callback.c:2 6c: No such file or directory: stdio.h
它正在查找下面的包文件

import ("github.com/golang-basic/go-curl")
我已经检查了“/usr/local/go/src/pkg/github.com/golang basic/go curl/”,文件已经存在

我真的失去了伙计们任何帮助都会非常感激的

更新******

大家好,thx的帮助…它的防御推进(安装xCODE等),但在编译

GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -o t1Login.linux t1Login.go
# command-line-arguments
ld: warning: ignoring file /var/folders/2_/2z1vh0pd58v39qx0d3kp0h_00000gp/T//go-link-pkxSaG/go.o, file was built for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being linked (x86_64): /var/folders/2_/2z1vh0pd58v39qx0d3kp0h_00000gp/T//go-link-pkxSaG/go.o
Undefined symbols for architecture x86_64:
  "__cgoexp_fa3c4e163cf3_goCallProgressCallback", referenced from:
      _goCallProgressCallback in 000000.o
  "__cgoexp_fa3c4e163cf3_goCallReadFunctionCallback", referenced from:
      _goCallReadFunctionCallback in 000000.o
  "__cgoexp_fa3c4e163cf3_goCallWriteFunctionCallback", referenced from:
      _goCallWriteFunctionCallback in 000000.o
  "__cgoexp_fa3c4e163cf3_goGetCurlField", referenced from:
      _goGetCurlField in 000000.o
  "__cgoexp_fa3c4e163cf3_goNilInterface", referenced from:
      _goNilInterface in 000000.o
  "_crosscall2", referenced from:
      _goGetCurlField in 000000.o
      _goNilInterface in 000000.o
      _goCallWriteFunctionCallback in 000000.o
      _goCallProgressCallback in 000000.o
      _goCallReadFunctionCallback in 000000.o
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
/usr/local/go/pkg/tool/darwin_amd64/6l: running clang failed: unsuccessful exit status 0x100

文件
c-callback.c
可能存在于
/usr/local/go/src/pkg/github.com/golang basic/go curl
中,但是:

  • 首先,路径很奇怪:
    /usr/local/go/src/pkg
    没有意义。
    例如,
    GOPATH
    应该设置为
    $HOME/go
    ,并且您的源代码应该位于
    $GOPATH/src/github.com/golang basic/go curl

  • 其次,缺少的文件是
    stdio.h
    ,这意味着为了完成
    /usr/include
    ,可能缺少一些开发包:

    • 像Unix上的
      sudo apt get install build essential
    • 或者,在你的情况下,比如

您需要使用CGO_ENABLED=1才能使用C


使用>MacOS 10.6时,$GOOS=linux应该是$GOOS=darwin,您安装了吗?在osx上构建c代码需要它。这里确实有curl包,但它在内部尝试构建一些c代码,但失败了,因为缺少头文件。@RickyA说得不错。我已经把你的评论包括在回答中了。