为编程爱好者分享易语言教程源码的资源网

网站首页 > 数据库 正文

MacOS Golang使用Sqlite3 交叉windows,liunux编译问题

三叶资源网 2022-08-18 21:18:50 数据库 898 ℃ 0 评论

# runtime/cgo

gcc_libinit_windows.c:7:10: fatal error: 'windows.h' file not found

  • 安装MacPorts
    https://www.macports.org/install.php#installing
    从上述连接选择对应的系统版本,下载对应的pkg文件
    双击安装,一路next加同意
  • 安装使用
    http://mingw-w64.org/doku.php/download/macports
    port not found!
    解决方案:find / -name "port" 有时候会出现在:/opt/local/bin/port下面
  • 执行
    sudo /opt/local/bin/port install mingw-w64
    等待完成安装
  • 安装结果会在以下路径产生程序
    /opt/local/bin/x86_64-w64-mingw32-gcc

以上是使用了c的编译方式进行交叉不同系统之间的编译

以上是实例:

CGO_ENABLED=0 GOOS=windows GOARCH=amd64  go build -o web.exe -ldflags "-H windowsgui" web.go 

有时候会报  undefined: SQLiteConn

接下来使用
CGO_ENABLED=1 GOOS=windows GOARCH=amd64  go build -o web.exe -ldflags "-H windowsgui" web.go 

会提示
# runtime/cgo
gcc_libinit_windows.c:7:10: fatal error: 'windows.h' file not found

这时候就用到了上面安装的MacPorts了

CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=/opt/local/bin/x86_64-w64-mingw32-gcc go build -o web.exe -ldflags "-H windowsgui" web.go 
  • web.go是包含sqlite3的驱动的,这个是在mac下进行编译windwos碰到的问题。主要是使用了交叉C编译器代替主机编译器。

https://github.com/mattn/go-sqlite3/issues/444

https://github.com/mattn/go-sqlite3/issues/372

github有人提问,解决方案就是使用c编译器代替主机编译器

Tags:

来源:三叶资源网,欢迎分享,公众号:iisanye,(三叶资源网⑤群:21414575

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

百度站内搜索
关注微信公众号
三叶资源网⑤群:三叶资源网⑤群

网站分类
随机tag
子类化UI取QQ昵称时时彩二星缩水软件Js加密自动更新软件游民星空易语言CEF3模块批量修改源码windows安全机制APIe2ee支持库动态加密文件拖拽DX2登录ITrayNotifyappium模块快看点视频上传支持库模版小米路由器Hadoop深度学习
最新评论