Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QT examples doesn't work in VSCode. #812

Open
kubilaykilinc opened this issue Mar 26, 2019 · 5 comments
Open

QT examples doesn't work in VSCode. #812

kubilaykilinc opened this issue Mar 26, 2019 · 5 comments

Comments

@kubilaykilinc
Copy link

kubilaykilinc commented Mar 26, 2019

Using Windows 8.1.
I installed correctly those :
1- Mingw 64
2- QT 5.12 (designer etc.)
3- therecipe/qt packages

qtsetup.exe worked successfuly. But i try therecipe/qt example codes in VS code (with golang extentions and tools). But they do not compile. I am getting some errors.
I tried compile this basic example.
https://github.com/therecipe/examples/blob/master/basic/widgets/main.go

But i've got this compile error.
exit status 3221225781

@therecipe
Copy link
Owner

Hey

For (go build/run or vscode builds) to work on windows, you will need set one (or two) env variables first.

Take a look at the qtenv.bat in your GOPATH/bin folder, it should contain two lines one for the PATH variable and maybe another one for the CGO_LDFLAGS variable.

These two variables are needed to be set inside vscode somehow.
But maybe it's also enough to set them globally using the advanced system settings, I'm not using vscode myself so I'm not sure.

@ManPython
Copy link

ManPython commented Aug 16, 2019

@therecipe

  1. I totaly don't understand the role of qtenv.bat. Not as script just as function in all stuff.
    a) why is added this to Go\bin\qtenv.bat
    I. where/when is used qtenv.bat?
@echo off
echo Setting up environment for Qt usage...
set PATH=C:\Users\Public\env_windows_amd64\5.13.0\mingw73_64\bin;C:/Users/Public/env_windows_amd64_Tools/mingw730_64\bin;%PATH%
echo To export the current PATH to your default CMD or PS env run
echo ------------------------
echo setx PATH "%%PATH%%"
echo ------------------------
echo and re-open the command line window

b) Is this symlinks are changed/upadted and the .bat in some cases of changes in vendor (.eg dir or as other path QT_DIR)?
I. Let we imagine that in case of some fails with generate/install qt by env_windows_amd64_513 want use msys2 or TDM.

  1. The CGO_LDFLAGS need more explain here https://github.com/therecipe/qt/wiki/Installation
    a) is this all what we need in example files to add? As: // #cgo CGO_CFLAGS_ALLOW=".*"

@kubilaykilinc did you solve your problem? I'm curios how people working with therecipe qt (are you sucess with deployments or you leaved this all?)?.

@ManPython
Copy link

ManPython commented Aug 16, 2019

  1. Next missunderstanding.. if I don't have qtsetup.exe and qtedeploy.exe the how was deplyed the Go\src\github.com\therecipe\qt\internal\examples\quick\calc\deploy\windows\calc.exe?
    a) how to run example that working (regarding my fights with vendor that qml working and widgets no working)?
C:\>go run "c:\Go\src\github.com\therecipe\qt\internal\examples\quick\calc\calc.go"
exit status 3221225781

#931 (comment)

@therecipe
Copy link
Owner

Sorry for the delay.

I totaly don't understand the role of qtenv.bat. Not as script just as function in all stuff.

The qtenv.bat needs to be used if you don't have a C compiler in your PATH.
You can then use this script to temporary add a C compiler to your PATH, without the need to permanently change the environment.
This is however only needed if you want to use go build/run to compile your applications.
It's not needed if you just want to build your applications with qtdeploy or qtdeploy -fast.
You can also (if you don't want to start the qtenv.bat each time before developing), run
setx PATH "%%PATH%%" after you started the qtenv.bat once to permanently add the C compiler dir to your PATH.

Is this symlinks are changed/upadted and the .bat in some cases of changes in vendor (.eg dir or as other path QT_DIR)?
I. Let we imagine that in case of some fails with generate/install qt by env_windows_amd64_513 want use msys2 or TDM.

Yes, the symlinks should be automatically changed if you use some of the qt tools (qtdeploy, qtminimal, qtrcc, qtmoc or qtsetup)
The msys2 builds also don't requiere the qtenv.bat, because the msys2 (mingw) shell adds a C compiler dir to your PATH as well.

The CGO_LDFLAGS need more explain here https://github.com/therecipe/qt/wiki/Installation
a) is this all what we need in example files to add? As: // #cgo CGO_CFLAGS_ALLOW=".*"

The CGO_LDFLAGS I talked above is only needed with the 512 env at the moment.
For this to work with the 513 env, you would just need to add
C:\Users\Public\env_windows_amd64\5.13.0\mingw73_64\bin;C:/Users/Public/env_windows_amd64_Tools/mingw730_64\bin
to your PATH.

The CGO_CFLAGS_ALLOW stuff from the wiki on the other hand, was just to work around a specific issue in Go 1.10.x, and you don't need to worry about this unless you want to use some old Go version.

Next missunderstanding.. if I don't have qtsetup.exe and qtedeploy.exe the how was deplyed the Go\src\github.com\therecipe\qt\internal\examples\quick\calc\deploy\windows\calc.exe?
a) how to run example that working (regarding my fights with vendor that qml working and widgets no working)?
C:>go run "c:\Go\src\github.com\therecipe\qt\internal\examples\quick\calc\calc.go"

I think this example did work, because it doesn't made use of qtmoc.
To compile it on your own, you would need to run something like this:

%GOPATH%\bin\qtenv.bat && cd c:\Go\src\github.com\therecipe\qt\internal\examples\quick\calc && go build -o calc.exe && calc.exe

@jayking0912
Copy link

By the way, in vs code launch.json, if you use "go mod"
you should add "-mod=vendor" in buildFlags, like this:
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceRoot}",
"env": {},
"args": [],
"buildFlags": "-mod=vendor"
}

it costs me much time 。😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants