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 go build -o

使用方式:

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 \
go build -o go-one-password-ui go-one-password-ui.go

github.com/mattn/go-gtk/pango

/usr/bin/i686-w64-mingw32-ld: cannot find -lpango-1.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lgobject-2.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lglib-2.0
collect2: error: ld returned 1 exit status

github.com/mattn/go-gtk/glib

/usr/bin/i686-w64-mingw32-ld: cannot find -lgobject-2.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lglib-2.0
collect2: error: ld returned 1 exit status

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:


sudoaptgetinstallgccmultilib
sudo apt-get install gcc-mingw-w64

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):


cdsrc
GOOS=windows GOARCH=386 CGO_ENABLED=1 CXX_FOR_TARGET=i686-w64-mingw32-g++ CC_FOR_TARGET=i686-w64-mingw32-gcc ./make.bash

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。
http://www.cnblogs.com/russellluo/p/3186786.html

作者: dawei

【声明】:永州站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐

联系我们

联系我们

0577-28828765

在线咨询: QQ交谈

邮箱: xwei067@foxmail.com

工作时间:周一至周五,9:00-17:30,节假日休息

返回顶部