我尝试用CGO_ENABLED=1在Windows上构建Go代码。我有一个.bat文件
set GOOS=linux
set GOARCH=amd64
set CGO_CFLAGS=-g -O2 -w
set CGO_ENABLED=1
go build main.go constants.go functions.go
但我错了:
gcc_linux_amd64.c: In function '_cgo_sys_thread_start':
gcc_linux_amd64.c:62:2: error: unknown type name 'sigset_t'
为我的Go应用程序构建一个容器会遇到环境变量方面的问题。
在我的本地机器上,我可以执行以下操作:
export GIN_MODE=release
go build -a
这将以一种方式编译我的应用程序,其中名为GIN的库将注意到GIN_MODE env变量并表现出不同的行为。
当我运行应用程序时,它将声明
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
- using env: export GIN_MODE=release
-
当我试图最小化一些docker图像时,我开始使用
FROM scratch
但当我这么做的时候我会得到
docker run --rm my/image:latest
standard_init_linux.go:228: exec user process caused: no such file or directory
但是,当我切换回
FROM alpine:latest
执行工作按预期进行。因此,我怀疑我的go应用程序中是否存在换行问题或缺少依赖项。相反,我认为这是因为系统希望/bin/sh可用。但是,与其在黑暗中探查并假设问题...
找出丢失内容的步骤是什么?如何找出文件或目录do
我一直使用cgo来连接Go和C。然而,当我试图对Go和C++做同样的事情时,每次我试图调用一个函数时都会得到一个编译错误。使用代码目录中的go build .,我得到以下错误:
./main.go: In function 'void _cgo_3612c872201c_Cfunc_getint(void*)':
./main.go:48:53: error: invalid conversion from 'void*' to '_cgo_3612c872201c_Cfunc_getint(void*)::<anonymous struct>
我正试图在我的Golang项目中使用archive/tar。但是,当我编译它时,我会得到以下错误:
/usr/local/go/pkg/tool/linux_amd64/link: /go-cache/10/1020ddd253c007d4f0bbed6c73d75297ac475bbc40d485e357efc1e7584bc24f-d(_go_.o): cannot use dynamic imports with -d flag
/usr/local/go/pkg/tool/linux_amd64/link: /go-cache/73/735aa16c44473681079e1f6b4a
在使用Cgo构建Go程序时,我遇到错误
/usr/lib/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: /tmp/go-link-373355991/000002.o: unrecognized relocation (0x2a) in section `.text'
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
我尝试用谷歌搜索这个问题,发现在libc6
我正在尝试在我的macbook上交叉编译ubuntu linux x86_64的Go。我已经按照概述的说明进行了操作,但是当我运行go-linux-amd64 build时,我得到了以下消息go build runtime: linux/amd64 must be bootstrapped using make.bash。任何在这方面的帮助都将不胜感激。
我已经在我的Windows 10上安装了1.7,我创建了测试程序,它在Windows中运行得很好。下一步是尝试使用Ubuntu在我的docker虚拟机上运行它。
我给找到了一些关于怎么做的信息
set GOARCH=amd64
set GOOS=linux
go tool dist install -v pkg/runtime
go install -v -a std
我在cmd中运行第1行和第2行,没有问题。在第3行,我有一个错误
go tool dist: open C:\Go\src\pkg\runtime: The system cannot find the path specifi
我在Windows机器上安装了Go 1.2,编写了一个虚拟程序,并将环境变量GOARCH和GOOS分别设置为"AMD64“和"linux”。
当我发出"go build“命令时,会收到一个错误:
go build runtime: linux/amd64 must be bootstrapped using make.bat
这是什么意思?
我正在尝试为我的Go项目创建一个Linux可执行文件。我的配置如下.config-ci.yml在我的gitlab项目中。 demo_job_1:
tags:
- cpf
- cpf-test
- testing
- unit-testing
script:
- go run test/main.go
- GOOS=linux GOARCH=amd64 go build
- go env
- cd test
- ./test
我一直试图运行./hack/update-all.sh脚本,并且在更新codegen时得到了这个错误:
$ ./hack/update-all.sh
Running in the silent mode, run with -v if you want to see script logs.
Running in short-circuit mode; run with -a to force all scripts to run.
Updating generated-protobuf
Updating codegen
# runtime
/usr/local/go/src/runtime
我在Windows上交叉编译用于Linux的Golang程序,使用:
go build -o myprog.bin myprog.go
为此,我必须设置环境变量GOOS=linux。由于我还在为windows编译一些程序,当我完成交叉编译时,我必须重新设置GOOS=windows。所以我有一个批处理文件,如下所示:
set GOOS=linux
go build -o myprog.bin myprog.go
set GOOS=windows
如果我碰巧同时为每个Linux和Windows编译两个程序,windows程序可能会被编译为Linux。是否有方法将环境变量的范围限制在windows上
我下载了。我正在尝试交叉编译它,以便ARM(PandaBoard)运行精简版本的linux。
在配置的初始设置中,我尝试
Shell$ ./configure --host=ARM
configure: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used.
checking for correct TEA configuration... ok (TEA 3.9)
我安装了金刚。
~/go/bin$ ls
go godoc gofmt
试着测试,但没有结果。
~/go/bin$ go version
-bash: /home/orc/go/bin/go: no such file or directory
我的$PATH:
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/orc/go/bin:
信息:
~/go/bin$ uname -m
x86_64
~/go/bin$ file go
go: ELF 64-bit LSB executable, x86-64, ver