How to make QtLinguist shipped with Qt 5.9.1 work?
If you are using Qt5.9.1 of mingw version, you may need to config the system path for mingw compiling tools.
In my case the culprit was the fact that Qt Creator had somehow picked different target ABIs for C and C++:
After fixing this, I managed to get lupdate
running with no issues.
The solution
Here is the solution I've found (rather hack-ish, but not too much), based on the info and advices kindly provided by n.m. in the comments under the question:
Create a translate.bat with the following single-line content:
"%programfiles(x86)%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" & lupdate.exe %1
and put it under %{CurrentProject:QT_INSTALL_BINS}
(in my case C:\Qt\Qt5.9.1\5.9.1\msvc2017_64\bin
). Make sure that the translate.bat contains the correct path to vcvars64.bat on your machine. You may as well put another version of vcvars if you need.
In Qt Creator select Tools/Options/Environment/External Tools and then Add Tool under Linguist category. Name it something like Create/Update TS files. Setup the fields for this entry as follows:
Executable:
%{CurrentProject:QT_INSTALL_BINS}\translate.bat
,Arguments:
%{CurrentProject:FilePath}
,Working directory:
%{CurrentProject:QT_INSTALL_BINS}
,
as shown here: External Tools, then apply the changes and close the Options window.
- Go to Tools/External/Linguist, select Create/Update TS files and now it should do the job as usual.
The background
Here is once again the link, provided by n.m. in the comments, which served as a base for this solution. Here is also n.m.'s explaination:
Running lupdate from the console most definitely requires that you run vcbars*.bat as described in the link I gave you. That's because lupdate wants to run the compiler and it has no idea where to find it. vcbars*.bat tweaks your PATH and other environment variables. In theory the GUI should set up the environment for you, but in practice it probably doesn't.
You have to run lupdate.exe
from VS2015 x86 Native Tools Command Prompt
console.