aqtinstall icon indicating copy to clipboard operation
aqtinstall copied to clipboard

Feature: Notify Qt installation for QtCreator autodetection

Open lucky62 opened this issue 3 years ago • 15 comments

Hello, I installed Qt and tools using aqtinstall - Exactly mingw810 both 32bit and 64bit. I started the QtCreator but no Qt versions were autodetected. So I added manually both versions (by browsing and selecting qmake).

Now QtCreator is reporting the problem: No compiler can produce code for this Qt version. So it means that also tools are not autodetected and must be added manually.

So question - why the autodetection of Qt versions and Tools is not working? They are installed on wrong place?

My directory structure (all aqtinstall defaults): image

lucky62 avatar Nov 12 '21 07:11 lucky62

Autodetection of Qt versions and tools is not something that aqt attempts to accomplish. For the most part, aqt simply downloads archives from the Qt repo and unzips them; it does nothing to tell QtCreator where to find Qt installations or compilers. I think you might be looking for the official Qt graphical installer; it is intended for this kind of thing.

If you don't want to use the official installer, you should be able to add kits for mingw manually manually.

If you feel strongly that aqt should be able to add kits to QtCreator automatically, and you know how to make aqt do it, I'm sure that @miurahr would welcome a PR. This sounds like a useful feature. I think this might be related to #332.

ddalcino avatar Nov 14 '21 18:11 ddalcino

Thanks for response. I need to clarify my point of view. I was not asking to modify aqt to be able to change the QtCreator configuration.

Qt Creator has its own autodetection. I was just asking why Qt Versions and Tools are not detected.

In the QtCreator Tools->Options->Kits->Compilers - when I clicked on the button Re-detect, then only C-Lang compiler is detected (probably because it is inside of the QtCreator folder):

QtCreatorAutoDetection

I don't know, how the QtCreator autodetection is working, But probably it will be enough to place the downloaded parts to the right place... Or to set some environment variables.. (PATH?)...

Anybody knows how the QtCreator autodetection works?

lucky62 avatar Nov 14 '21 19:11 lucky62

Anybody knows how the QtCreator autodetection works?

No, this sounds outside the scope of aqtinstall, and I think you'll have better luck asking at the Qt forums.

aqt installs everything directly to the output directory that you specify. If you run aqt install-tool windows desktop <mingw> --outputdir ./Qt, it will unzip the mingw archives directly in ./Qt. Any paths beyond that are encoded directly into the archive, and aqt will not modify them. aqt does not decide whether or not to place anything in a Tools folder or a 5.15.2 folder.

If it's at all helpful, I have a local Qt installation installed with the official installer, and the directory structure looks like this:

Qt
|-5.12.10
| |-mingw73_32
|-Tools
  |-mingw730_32
  |-QtCreator
  |-QtInstallerFramework

In QtCreator, the auto-detect locates the Qt/Tools/mingw730_32/bin/g++.exe compiler automatically, and it is not in my PATH variable. It also automatically detects several other compilers; some of these are in my PATH and some are not. It is not clear to me how it is detecting these.

ddalcino avatar Nov 14 '21 20:11 ddalcino

@lucky62 Please see a qtscript(installscirpt.qs) inside meta.7z package (for example 6.2.1 mingw) .

If you want to realize auto-detection, you should do something similar with the script does.

You can find a part

            if (installer.value("SDKToolBinary") == "")
                return;

            component.addOperation("Execute",
                                   ["@SDKToolBinary@", "addQt",
                                    "--id", component.name,
                                    "--name", "Qt %{Qt:Version} MinGW 64-bit",
                                    "--type", "Qt4ProjectManager.QtVersion.Desktop",
                                    "--qmake", qmakeBinary,
                                    "UNDOEXECUTE",
                                    "@SDKToolBinary@", "rmQt", "--id", component.name]);

            var kitName = component.name + "_kit";
            component.addOperation("Execute",
                                   ["@SDKToolBinary@", "addKit",
                                    "--id", kitName,
                                    "--name", "Desktop Qt %{Qt:Version} MinGW 64-bit",
                                    "--Ctoolchain", "@MINGW810_TCID@" + ".gcc",
                                    "--Cxxtoolchain", "@MINGW810_TCID@" + ".g++",
                                    "--qt", component.name,
                                    "--debuggerid", "@MINGW810_DBGID@",
                                    "--devicetype", "Desktop",
                                    "UNDOEXECUTE",
                                    "@SDKToolBinary@", "rmKit", "--id", kitName]);

This tells QtCreator about the new installation of gcc and component.

miurahr avatar Nov 15 '21 00:11 miurahr

@miurahr this is not the "auto-detection" - this is the "auto-configuration" and some SDK Tool is required for this.

Auto-Detection is directly in the QtCreator. I was looking inside the source code which procedure is called when Re-detect button is pressed - but the code is not very clear to me...

lucky62 avatar Nov 15 '21 15:11 lucky62

... and some SDK Tool is required for this.

The SDK Tool should be at Qt/Tools/QtCreator/bin/sdktool.exe on Windows; I'm not sure where it is on other platforms.

ddalcino avatar Nov 15 '21 17:11 ddalcino

@lucky62 "auto-configuration" can be a feature request for aqtinstall but if you want to improve QtCreator "auto-detection" as you mentioned, it is not an issue of aqtinstall, isn't it?

miurahr avatar Dec 04 '21 08:12 miurahr

I agree. This is a feature request for aqtinstall. Not a bug. It will be very nice if aqtinstall will do something similar as official install script mentioned in your post before.

lucky62 avatar Dec 10 '21 17:12 lucky62

@lucky62 Please see a qtscript(installscirpt.qs) inside meta.7z package (for example 6.2.1 mingw) .

If you want to realize auto-detection, you should do something similar with the script does.

I think it would be easy for us to download and unzip the appropriate meta.7z archive that contains installscript.qs. I have no idea how we could run the installscript.qs file. To implement this feature properly, running that file is necessary.

The only alternative that I see is to re-implement every installscript.qs file, in Python, for every version of Qt, every architecture, and every platform. I think it's possible to do this, and there may be shortcuts to reduce the amount of work required, so that you don't need to reimplement every permutation of version/arch/platform. Additionally, I think you would need to test this code exhaustively (run the installer on every permutation of version/arch/platform in ci), and I don't think that's sustainable.

If we can prove that the installscript.qs files are not substantially different from each other for each permutation of version/arch/platform, maybe it would be sustainable to reimplement it in Python without exhaustive testing.

Does anyone know how to run a QScript file (.qs) independently of the Qt installer? Does a "NodeJS/QS" exist somewhere?

ddalcino avatar Dec 11 '21 17:12 ddalcino

Does anyone know how to run a QScript file (.qs) independently of the Qt installer? Does a "NodeJS/QS" exist somewhere?

installscript.qs calls functions provided by QtIFW, such as binary patching, I think it is not possible to run indenendently of the Qt installer.

miurahr avatar Dec 19 '21 23:12 miurahr

If it’s impossible to run the installscript.qs independently of QtIFW, then the alternative is to rewrite every installscript.qs in Python. IMHO, that approach is unsustainable. I don’t think it’s a good idea to try to implement this feature.

ddalcino avatar Dec 19 '21 23:12 ddalcino

IMHO, that approach is unsustainable. I don’t think it’s a good idea to try to implement this feature.

I'm also think it is not sustainable, but experimental #474 illustrate how it can be implemented(not tested) @lucky62 may be interested in making this working.

miurahr avatar Jan 11 '22 12:01 miurahr

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

github-actions[bot] avatar Feb 11 '22 00:02 github-actions[bot]

#474 may be work for you, @lucky62 Could you try?

miurahr avatar Feb 11 '22 02:02 miurahr

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

github-actions[bot] avatar Mar 14 '22 00:03 github-actions[bot]