ubuntu golang使用sqlite

前端之家收集整理的这篇文章主要介绍了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 \ @H_403_9@ 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 @H_403_9@ /usr/bin/i686-w64-mingw32-ld: cannot find -lgobject-2.0 @H_403_9@ /usr/bin/i686-w64-mingw32-ld: cannot find -lglib-2.0 @H_403_9@ collect2: error: ld returned 1 exit status

github.com/mattn/go-gtk/glib

/usr/bin/i686-w64-mingw32-ld: cannot find -lgobject-2.0 @H_403_9@ /usr/bin/i686-w64-mingw32-ld: cannot find -lglib-2.0 @H_403_9@ 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。 @H_403_9@ http://www.cnblogs.com/russellluo/p/3186786.html

猜你在找的Ubuntu相关文章