Hacking:Tools:QtCreator:Windows10

From Seamly
Revision as of 03:02, 13 January 2017 by Slspencer (talk | contribs) (create page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

About this page

This page contains steps to:

  • Install Qt 5.8 on 64-bit 4-processor desktop with Windows 10. Note that Qt 5.8 contains Qt Creator 4.2.0
  • Configure Qt Creator with:
    • custom compiler
    • custom compiler kit
    • system environment library variables
  • Configure Valentina project in Qt Creator to:
    • compile with custom compiler kit
    • compile for Release or Debug

Qt Framework and Qt Creator are built to work with 32-bit MinGW (Minimalist GNU C/C++ compiler for Windows). There are projects which have built Qt using the 64-bit MinGW compiler, but these don't seem to be kept up to date. And they may produce unexpected results for Valentina.

Qt Creator's configuration includes definitions for a compiler, compiler kit, and library paths.
Additional build/compiler/environment options can be customized for each project. Note: The library paths are sometimes required to enable libraries to be found during qmake when compiling Valentina code.

Install Qt 5.8

Create a Qt account at [1], then login. Go to [2] and click on the Download button. It will detect the correct file to download for your operating system, in this case the file downloaded was qt-unified-windows-x86-2.0.4-online. Open your Downloads folder, right click on the file, and select Run as administrator. Follow the install instructions. You may accept the defaults for components to install, or you may select what you need. In this case I deselected all Qt versions except 5.8. Do not change any options for MinGW. Under the Tools section QtCreator is unselectable -- it will always be installed.

Define system information

Open Qt Creator. Select Tools/Options/Build&Run/Compilers. Under the Auto-detected section, select the C++ compiler MinGW 5.3.0 32bit2. Note the directory path.

The following information is required to define the custom compiler, custom compiler kit, and system environment library variables.
Examples are given but should be confirmed for each Qt upgrade.

  • Compiler flags -j2 (one-half of the 4 processors, to prevent system lockup during multiprocessor compilation)
  • Qt directory C:\Qt
  • Qt Creator directory C:\Qt\Tools\QtCreator
  • Qt Creator MinGW C++ Compiler C:\Qt\Tools\mingw530_32\bin\g++.exe
  • Qt Creator MinGW C++ Library directory C:\Qt\Tools\mingw530_32\lib\
  • Qt qmake directory C:\Qt\5.8\mingw53_32\bin\
  • Qt qmake Makespec directory C:\Qt\5.8\mingw53_32\mkspecs\win32-g++\
  • Qt qmake Makespec file C:\Qt\5.8\mingw53_32\mkspecs\win32-g++\qmake.conf
  • Qt MinGW C++ Compiler C:\Qt\5.8\mingw53_32\bin\g++.exe
  • Qt MinGW C++ Compiler Library directory C:\Qt\5.8\mingw53_32\lib\

Confirm C++ compiler and qmake directories

Open Qt Creator and open Tools/Options/Build & Run. Select the Compilers tab. Note the directory for the C++ compiler.
Select the Qt Version tab. Note the directory for qmake.

Confirm kit

Select the Kits tab.
The Auto-detected kit should be Desktop Qt 5.8 MinGW 32bit (default)

Configure the Valentina project

Select the General tab.
In the Directory field, select the directory containing your local clone of Valentina, or if you have multiple Qt projects select the parent directory of your projects.
Check the Open Compile Output pane when building option, leave all other options at default settings.
Click Apply and OK to close the Tools/Options window.

Click Open Project button.
Select the Valentina file from your local clone of Valentina.
The Configure Project window opens. Click the Configure Project button.
Click on the Projects wrench icon in the left side menu.
Select the Build hammer icon to open the Build Settings options.

  Next to Edit Build Configuration, select Debug from the picklis
t.
Click on the Details button for the Make instruction under Build Steps.
Enter -j2 in the Make Arguments field to enable use of multiple processors.
Go back to Edit Build Configuration, select Release, and enter -j2 in Make Arguments.

Select the Run green triangle icon to open the Run Settings options.

  Next to Run Configuration select valentina from the picklist.

Save configuration and project

Select File/Save All. You're now ready to build Valentina. From the Build menu option, select Run qmake followed by Build Valentina.
Subsequent builds require Clean Project Valentina, Run qmake, Rebuild Project Valentina.



Create a text file like the example below with your system directory information. Place double quotes "" around each path definition, separate directories with : symbol.
All entries will be Qt Compiler Library directory:Qt Creator Library directory except for QTDIR.
This information will be copy-pasted into Qt Creator.

Example text file:

QTDIR = "$home/Qt/5.7/"
LD_LIBRARY_PATH = "$home/Qt/5.7/gcc_64/lib:$home/Qt/Tools/QtCreator/lib/Qt/lib/"
LD_RUN_PATH = "$home/Qt/5.7/gcc_64/lib:$home/Qt/Tools/QtCreator/lib/Qt/lib/"
QMAKE_LFLAGS_RPATH = "$home/Qt/5.7/gcc_64/lib:$home/Qt/Tools/QtCreator/lib/Qt/lib/"
QMAKE_RPATH = "$home/Qt/5.7/gcc_64/lib:$home/Qt/Tools/QtCreator/lib/Qt/lib/"
QMAKE_RPATHDIR = "$home/Qt/5.7/gcc_64/lib:$home/Qt/Tools/QtCreator/lib/Qt/lib/"

In Qt Creator select Tools/Options/Build&Run/Kits:

  • Click on triangle next to Manual section and click Add. The 'Unnamed' compiler kit appears in the Manual section.
  • Edit the following fields, don't use quotes:
    • Name: Enter a name (ex: Manual Multiprocessor Qt 5.7.0 Gcc 64bit).
    • Compiler: Click on triangle in Compiler field and select your custom compiler.
    • Environment:
      • Click on Change button to the right of Environment.
      • Copy-paste all lines from your text file into the field. The double quotes as entered in the text file are required, do not remove them.
    • Qt version: Confirm that it reflects your build (ex: QT 5.7.0 GCC 64-bit)
    • Qt mkspec: Enter your Qt Makespec (ex: linux-g++-64)
  • Click on Apply to save, then OK to close the window.

Configure Valentina with custom compiler kit

In Qt Creator, select File/Open File or Project. The Valentina Build & Run project window will open, or the Configure Project window will open.
If the Configure Project window opens:

  • Check the box next to your custom compiler kit
  • Click Configure Project at bottom of window to save and close. The Build & Run project window will open.

In the Valentina Build & Run project window:

  • Click on Projects in left side menu. The Valentina Build & Run window will open.

In the Valentina Build & Run window:

  • Click on the 'Build' half of the Build | Run button near the top of the window. The 'Build' half of the button will turn light grey.
  • In Build Settings, Edit build configuration section, select Release from the picklist. ("Release" is best for building the nightly code, "Debug" is used for debugging your code if you are a code contributor to Valentina).
  • In General section, check the box next to Shadow build.
  • In Build Steps, Make section, click on Details.
    • In Make arguments enter -j4, don't use quotes.
  • In Build Environment/Use system environment section, click on Details. The list of System Environment variables will appear.
    • Add the six environment variables you added to the custom compiler kit.
      • Click Add, enter QTDIR
      • Click Add, enter LD_LIBRARY_PATH
      • Click Add, enter LD_RUN_PATH
      • Click Add, enter QMAKE_LFLAGS_RPATH
      • Click Add, enter QMAKE_RPATH
      • Click Add, enter QMAKE_RPATHDIR
    • Copy-paste the directory string for each of these variables, do not include the quote marks.
      • Double-click <VALUE> next to QTDIR, copy-paste the QTDIR Directory from your text file, exclude quotes. Repeat for each added variable.
  • Click on the Manage Kits square button at top left of the window. The Tools/Options/Build & Run/Kits window will open.

In the Tools/Options/Build & Run/Kits window:

  • Click on your custom compiler kit.
  • Confirm that Compiler is your custom compiler and Qt Version is correct.
  • Click the Make Default button.
  • Click Apply then OK to save and return to the Valentina Build & Run window.

In the Valentina Build & Run window:

  • Click on the Monitor icon in the lower left side menu. A dark box appears showing three columns Project, Build, Run.
    • Under 'Project' select 'Valentina'
    • Under 'Build' select 'Release'
    • Under 'Run' select 'valentina'
  • Select File/Save All from QT Creator top bar menu.

Now smile and relax, you're done!!!!!!!!!