golang notes (8)---therecipe/qt binding

6/5 update on therecipe/qt binding:

refer to: https://github.com/therecipe/qt

export GO111MODULE=off; go get -v github.com/therecipe/qt/cmd/... && $(go env GOPATH)/bin/qtsetup test && $(go env GOPATH)/bin/qtsetup -test=false

Note: no need to install Qt library. therecipe/qt/cmd will automatically install therecipe/env_linux_amd64_513.

(00:35 dabs@CNU1343VF8 src) > pwd
/home/dabs/go/src

(00:35 dabs@CNU1343VF8 src) > tree github.com/ -L 2
github.com/
├── [dabs     4.0K]  sirupsen
│   └── [dabs     4.0K]  logrus
└── [dabs     4.0K]  therecipe
    ├── [dabs     4.0K]  env_linux_amd64_513
    └── [dabs     4.0K]  qt

How to build qt project?

git clone https://github.com/therecipe/examples.git therecipe_examples
(00:38 dabs@CNU1343VF8 golang) > go env -w GO111MODULE=off

(00:38 dabs@CNU1343VF8 golang) > go env | grep GO111
GO111MODULE="off"

(00:39 dabs@CNU1343VF8 golang) > $(go env GOPATH)/bin/qtdeploy test desktop therecipe_examples/basic/widgets/

(00:40 dabs@CNU1343VF8 golang) > tree therecipe_examples/basic/widgets/ -L 3
therecipe_examples/basic/widgets/
├── [dabs     4.0K]  deploy
│   └── [dabs     4.0K]  linux
│       ├── [dabs     4.0K]  lib
│       ├── [dabs     4.0K]  plugins
│       ├── [dabs     4.0K]  qml
│       └── [dabs     2.5M]  widgets
├── [dabs     4.0K]  linux
└── [dabs     1.4K]  main.go

6 directories, 2 files

 

More about the GO111MODULE environment variable(from 'go help modules'):

For more fine-grained control, the go command continues to respect
a temporary environment variable, GO111MODULE, which can be set to one
of three string values: off, on, or auto (the default).

If GO111MODULE=on, then the go command requires the use of modules,
never consulting GOPATH. We refer to this as the command
being module-aware or running in "module-aware mode".

If GO111MODULE=off, then the go command never uses
module support. Instead it looks in vendor directories and GOPATH
to find dependencies; we now refer to this as "GOPATH mode."

If GO111MODULE=auto or is unset, then the go command enables or disables
module support based on the current directory.
Module support is enabled only when the current directory contains a
go.mod file or is below a directory containing a go.mod file.

In module-aware mode, GOPATH no longer defines the meaning of imports
during a build, but it still stores downloaded dependencies (in GOPATH/pkg/mod)
and installed commands (in GOPATH/bin, unless GOBIN is set).

 

Use 'go build' instead of 'qtdeploy':

refer to: https://www.cnblogs.com/apocelipes/p/9300335.html

cd your_project
qtmoc # 使用moc處理Qt擴展語法
qtrcc # 如果使用了qrc機制需要使用此命令
go build -o project_name

 

Added 2020/6/6:

difference between 'go build' and 'qtdeploy'

(23:51 dabs@CNU1343VF8 ngapp) > tree . -L 3
.
├── [dabs     4.0K]  deploy
│   └── [dabs     4.0K]  linux
│       ├── [dabs     4.0K]  lib
│       ├── [dabs     2.4M]  ngapp
│       ├── [dabs     4.0K]  plugins
│       └── [dabs     4.0K]  qml
├── [dabs     4.0K]  linux
├── [dabs      196]  main.go
├── [dabs     107M]  ngapp
└── [dabs     3.0K]  ngapp.go

It seems that executable by 'go build' is significantly larger than that by 'qtdeploy':

  • ngapp is 107M when using 'qtmoc && go build -o nagpp'
  • and ngapp is 2.4M when using 'qtdeploy test desktop ../ngapp'
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章