ubuntu golang使用sqlite
使用方式:http://studygolang.com/articles/5456 https://siongui.github.io/2016/01/09/go-sqlite-example-basic-usage/ 交叉编译$ CC=i686-w64-mingw32-gcc-win32 GOOS=windows GOARCH=386 CGO_ENABLED=1 github.com/mattn/go-gtk/pango/usr/bin/i686-w64-mingw32-ld: cannot find -lpango-1.0 github.com/mattn/go-gtk/glib/usr/bin/i686-w64-mingw32-ld: cannot find -lgobject-2.0 I also needed to make sure I had several different gcc packages installed on my Ubuntu machine to support this process. I installed them with:
The trickiest part though was building the various bits. I used make.bash. Perhaps there is a way to do this with all.bash. But I wasn’t sure what that actually did and whether it would pick up the particular environment variables I wanted to specify. So I ran make.bash multiple times. I start by building the Windows stuff (I’ll explain why in a sec):
This enabled CGO and specifies special C and C++ compilers to use in order to build the native exes. This is for the win32 platform. Then,I run the command again for win64 but add the –no-clean option: $ GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CXX_FOR_TARGET=x86_64-w64-mingw32-g++ CC_FOR_TARGET=x86_64-w64-mingw32-gcc ./make.bash –no-clean Finally,I do a build for native Linux (again with –no-clean) $ GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CXX_FOR_TARGET=g++ CC_FOR_TARGET=gcc ./make.bash –no-clean Now you might wonder why I built them in this order. I played around with this quite a bit actually. The issue is that these builds are somehow “stateful”. The last build seems to set some defaults somewhere or something. You’d think that it would be sufficient to just specify GOOS and GOARCH whenever you ran the go tool,but it isn’t. If I build Linux first and Windows last,the Linux version wouldn’t work (because the last build was Windows and that messed up Linux). And yes,building Linux last messes up the Windows builds. BUT,that can be overcome by setting some environment variables. The way I dealt with this was to create some special scripts: $ echo ‘export GOOS=windows; export GOARCH=386; export CGO_ENABLED=1; export CXX=i686-w64-mingw32-g++; export CC=i686-w64-mingw32-gcc’ > go-win32 $ echo ‘export GOOS=windows; export GOARCH=amd64; export CGO_ENABLED=1; export CXX=x86_64-w64-mingw32-g++; export CC=x86_64-w64-mingw32-gcc’ > go-win64 Notice the fact that I explicitly set the values of CXX and CC. What I normally do is just source these,i.e.,(NOTE THE ‘.’) $ . go-win32 This sets the environment variables needed to perform a win32 build. After that,I can just use the go tool as usual,e.g. 数据库创建在SQLite中,自增字段需要使用关键字INTEGER PRIMARY KEY。 (编辑:甘南站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- qt – 错误:QApplication:没有这样的文件或目录
- 如何在Ubuntu上安装Titanium Studio?
- Ubuntu Desktop 16.04下安装Docker
- Ubuntu16.04 Caffe 安装步骤记录(超详尽)
- Ubuntu 搭建强大的 IDE —— Vim + Vundle + 插件
- Ubuntu14.04下OpenCV2.4.10安装
- Ubuntu-**-amd64.iso 与 Ubuntu-**-i386.iso不同
- Ubuntu安装Python的mysqlclient
- 0安装FastDFS到ubuntu
- Ubuntu使用VNC连接windows错误: connection: no