为编程爱好者分享易语言教程源码的资源网
好用的代理IP,游戏必备 ____广告位招租____ 服务器99/年 ____广告位招租____ ____广告位招租____ 挂机,建站服务器
好用的代理IP,游戏必备 ____广告位招租____ 服务器低至38/年 ____广告位招租____ ____广告位招租____ 挂机,建站服务器

网站首页 > 数据库 正文

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

三叶资源网 2022-08-18 21:18:50 数据库 234 ℃ 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
支持库教程例子QQ好友批量点名片赞邮箱轰炸器宏插件吃鸡泰服矩阵WebSocket ClientEC反编译Shell外壳编程windows安全机制API登录E2EE分布式任务微信群发Socket图片生成器U盘锁屏辅助源码觅风易语言教程软件自动更新终极版哈希表
最新评论