📜 ⬆️ ⬇️

We collect qt-4.8.7 and qt creator with the help of mingw-w64 on windows (10), with bonus we tweak to work with github

A few words about what it took at all: I had a simple situation - there was no fast Internet and there was a computer with cleanly installed windows 10. In addition, the project I’m picking requires building both under 32 and 64 bit architecture, therefore It seemed to me that the presence of Qt, equally configured and compiled under these architectures will be only a plus.

0) It is advisable to chop off in advance the services of Windows Search and Superfetch and Windows Defender. They in our operations will only slow down the system, and we will soon need resources. In addition, it is very useful to make the input language the default English.

1) Create the folder “C: \ QT” - here our assemblies will live.

2) To begin with, we certainly need the mingw-w64 compiler itself. Download the installer here .
')
3) Install in turn both versions:
first installation:
Version - 5.2.0 - the last at the time of this writing;
Architecture - i686 - at first we put the 32 bit version (don't let it scare you that it is not i386, i686 is Intel Pentium Pro and higher, you can run 2k Windows on something more ancient - good luck!)
Threads - win32 - if you are not porting source files from Unix, it is better to choose native ones;
Exeption - sjlj - I need so, if you need others - for God's sake;
Build revision - 1 again, the last one at the time of this writing;
The assignment chose “C: \ mingw-w64-i686” because from Program Files there may be problems with spaces in the paths of qt.
The second installation is all the same except:
Architecture - x86_64;
Path "C: \ mingw-w64-x86_64";
I also removed the “create shortcuts” checkbox, otherwise they will be overwritten by the 64 bit version, which is inconvenient for me.
If you do not want to produce many folders in the root, you can put it in "C: \ QT \ mingw-w64-i686" and "C: \ QT \ mingw-w64-x86_64", respectively, to the architectures, it does not matter.

4) Download the QT 4.8.7 library source code here

5) We unpack Qt itself (here it’s better to take care of the presence of the 7zip program for the Windows archiver will first unpack into a temporary folder, then copy the small files from it, idiot, and then create an additional folder inside with the same name) immediately into 2 copies of "C: \ QT \ qt-4.8.7-mingw-w64-i686" and "C: \ QT \ qt-4.8.7-mingw-w64-x64" (the second is needed in case of configuration errors, it is much faster to rename copy and letting the background unpack one more thing, than to wait for the mingw32-make confclean to work). If you are not sure of the archiver, we check that the bin, util, src, etc. folders are immediately in these folders, if the archiver has created another nested folder, we take out the content to a higher level.

6) Go to the system properties and change the PATH variable (I’ve done the normal interface for this in my 10-ke), adding the path to the 32-bit version of the compiler, I have this: “C: \ mingw-w64-i686 \ mingw32 \ bin ". If all of a sudden you have PATH paths to other compilers, temporarily remove them from there.

7) Run cmd from admin (this is important) and enter:

g++ -v


There should be an infa about the compiler, if this does not happen, then the compile is installed incorrectly, we are looking for an error in the previous steps. If the information is displayed, we check that we did not mess up anything: we really run the 32 bit version, and that it is the one we installed in the previous steps, and not from the original mingw without w64 (these are essentially different projects) or, God forgive me, visual studio.

If everything is fine, go to the folder with Qt:

cd C:\QT\qt-4.8.7-mingw-w64-i586


we start there a configuration somehow so:

.\configure -debug-and-release -opensource -confirm-license -platform win32-g++ -graphicssystem raster -no-openssl -nis -iconv -system-proxies -no-freetype -plugin-sql-odbc -plugin-sql-sqlite -qt-style-windows -qt-style-windowsxp -qt-style-windowsvista -qt-style-plastique -qt-style-cleanlooks -qt-style-motif -qt-style-cde -qt-style-windowsce -qt-style-windowsmobile -qt-style-s60


in this config max all that can be collected without dependencies. I do not really need openssl, otherwise it needs to be assembled in advance. If time is critical, you can disable the examples, do not collect additional themes and odbc plugin. You can get help on options like this: ". \ Configure -help". Next, wait a few minutes while the configuration runs, and run the compilation:

mingw32-make -j4


I have a 4 core processor for this option -j4 it means to compile in 4 threads. At once I will make a reservation, compilation with this option does not go through to the end, crashes on qtdeclarative with an error copying the file, it seems that the dependencies are incorrectly written somewhere. It was enough for me to run the compilation after the crash again. The error by the way was repeated on the 64 bit version. On the core i5-3570 with 8 gigs of opera, compiling one version into 4 threads takes almost 2 hours.

8) If you have a slow Internet, while Qt compiles itself, you can put qt creator 3.2.2 on download (this is the latest version, which compiles to 4.8.x), ActivePerl-5.20.2! 32 bit version! and msysgit! 32 bit version! The versions mentioned here are the last ones at the time of this writing, and, accordingly, those with which I worked. If you have something not gone for newer, try indicated by me. I’ll warn you right away that it’s very undesirable to put msysgit before building qtcreator, the creator will not normally build if you see sh.exe in the patch, and for normal work with the git it should be set up with the PATH prescription.

9) Install Perl: I did not set the documentation and examples, I made the destination “C: \ perlx86”. Do not remove the checkbox "Add perl to the PATH environment variable". After installation in the command line (of course not in the one in which Qt is compiled), we write “perl -v”, version information should appear.

10) Unpack the qt creator in "C: \ QT \ qt-creator-opensource-src-3.2.2", we also check that there is no subfolder inside, but immediately the bin folder and the rest.

11) We are waiting for qt to be compiled. There will be no direct messages that the compilation was successful. My last was going to be 'C: /QT/qt-4.8.7-mingw-w64-i586/demos/declarative/webbrowser'. You can run qtdemo.exe for verification, run examples. Open the environment variable editor again, append the PATH to “C: \ QT \ qt-4.8.7-mingw-w64-i586 \ bin”. Again, we see that this is the only qt profile in PATH. We check ourselves by restarting the command line and typing "qmake -v".

12) Open the block file “C: \ QT \ qt-creator-opensource-src-3.2.2 \ src \ libs \ utils \ tcpportsgatherer.cpp”, we find the line
 #if __GNUC__ == 4 && (!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 2) 

and change it to
 #if __MINGW64_VERSION_MAJOR == 5 || (__GNUC__ == 4 && (!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 2)) 

13) Restart cmd again from the admin. We collect creator in a new folder:

mkdir C:\QT\qt-creator-3.2.2-x86
cd C:\QT\qt-creator-3.2.2-x86
qmake -r ../qt-creator-opensource-src-3.2.2/qtcreator.pro
mingw32-make release -j4


I hope you don’t need to repeat the -j4 option.

14) We are waiting for the end of the compilation, run qtcreator, make sure that it works. We are closing, there is still nothing to tune in it. If it’s too pity for disk space and operatives, you can drop the compiled creator into the folder with Qt (copy only the bin, lib, share folders) and drop the missing dll files from mingw into the bin folder. Humanly, it’s the other way around: remove the compiler and Qt from the PATH and copy the dll files from the Qt bin and compiler folders into the bin creator folder.

15) Open the PATH editor again. Remove the path to the compiled Qt “C: \ QT \ qt-4.8.7-mingw-w64-i586 \ bin” from there and change the path to the compiler c “C: \ mingw-w64-i686 \ mingw32 \ bin ”to“ C: \ mingw-w64-x86_64 \ mingw64 \ bin ”. Again, we restart cmd from the admin and check what we get.

g++ -v


if everything is OK, we do everything the same as in step 6, only the path we now will be different.

cd C:\QT\qt-4.8.7-mingw-w64-x86_64
.\configure -debug-and-release -opensource -confirm-license -platform win32-g++ -graphicssystem raster -no-openssl -nis -iconv -system-proxies -no-freetype -plugin-sql-odbc -plugin-sql-sqlite -qt-style-windows -qt-style-windowsxp -qt-style-windowsvista -qt-style-plastique -qt-style-cleanlooks -qt-style-motif -qt-style-cde -qt-style-windowsce -qt-style-windowsmobile -qt-style-s60
mingw32-make -j4


16) Now, while compiling the 64-bit version of Qt, you can also do git (jit, I don’t know which transcription is more correct). Install msysgit v2.6.3! 32 bit version! run the installer directly from the admin, otherwise it will deliver us the version only for the local user, we do not need it. I chose the path "C: \ msysGitX86". In the next step, you can poke a checkbox that will create a shortcut to the console on the desktop. In another step, select “Use git from the Windows Command Promt”, I also chose “Use Windows` default console window” for the terminal, the rest to the amateur or default.

There is a wonderful article on blogspot about how to make friends qt creator and github. However, it does not give instructions on what to do if the screw on which it is all set is burned with a blue flame. Let's try to fill this gap.

17) Run git-bash from the admin from the shortcut that the installer created for us

we make settings, of course, substituting the mail on which the githabe account is registered and your nickname

git config --global user.email "myMail@example.com"
git config --global user.name "myGithubNick"
git config --global push.default simple


Generate a new key pair for ssh:

ssh-keygen -t rsa -C "myMail@example.com"


3 times we zhmakayem enter, go to the browser in your profile on githabe, delete the old key (unless of course we are not going to use it, but it is lost like mine) and add a new one.

Try to clone the existing repository:

mkdir C:\\myproject
cd C:\\myproject
git clone git@github.com:myGithubNick/mysuperproject.git


note that the user is “git” and not a nickname; nickname is indicated after the colon. In addition, there should be no https: // or git: // in front of the address, if you receive a message that you need to use https, then the github does not recognize the owner of the repository, look for problems with keys or ssh. If everything is in order, git will make us a copy of the repository in the mysuperproject folder. Go into it and check that the repository is working, and we have all the rights

cd ./mysuperproject
git remote -v
touch .testfile.txt
git add .testfile.txt
git commit -m test
git push
git reset --hard HEAD~1
git push -f


Of course there should be no errors, if there is something wrong with the installation of the gita or ssh.

18) Wait for the 64 bit version of Qt to compile. We remove the 64-bit compiler from PATH, either completely or change to the 32-bit version, which is more convenient. Open the notebook “C: \ QT \ qt-4.8.7-mingw-w64-x86_64 \ mkspecs \ win32-g ++ \ qmake.conf”, immediately after the comments we add “QMAKE_TARGET.arch + = x86_64”, save, close.

19) Start the creator again (if it stopped running now, it means something extra is in the path or not all of the libraries we gave it).

Open Tools (Tools) -> Options (Options). Immediately in the Environment section on the General tab, we are asked to enter the path to the patch command, you can use "C: \ msysGitX86 \ usr \ bin \ patch.exe". Go to the External Tools (External Tools) - rule the way.

Go to the Build & Run section, go to the Debuggers tab, click Add, give the name: “mingw32-w64-gdb”, path: “C: \ mingw-w64-i686 \ mingw32 \ bin \ gdb.exe ". Click Add again, giving the name: "mingw64-w64-gdb", path: "C: \ mingw-w64-x86_64 \ mingw64 \ bin \ gdb.exe".

Go to the Compilers tab, click Add (Add) -> MinGW, if there is no name defined in the path, give the name “MinGW32-W64” and the path “C: \ mingw-w64-i686 \ mingw32 \ bin \ g ++. Exe” ( You can make a copy for convenience, not scary). Add one more: the name "MinGW64-W64" is the path "C: \ mingw-w64-x86_64 \ mingw64 \ bin \ g ++. Exe", ABI choose 64bit if there is one.

Go to the Qt Profiles (Qt versions) tab. If the 32-bit profile is not in the path, first add its “C: \ QT \ qt-4.8.7-mingw-w64-i586 \ bin \ qmake.exe”. Then we add 64 bit "C: \ QT \ qt-4.8.7-mingw-w64-x86_64 \ bin \ qmake.exe". My names are "Qt 4.8.7 mingw-w64 i586" and "Qt 4.8.7 mingw-w64 x86_64", respectively.

Go to the Kits tab, first configure the Desktop profile:
Name: Desktop
File system name: x86
Device Type: Desktop
Device: Local PC
Sysroot: - leave blank
Compiler: MinGW32-W64
Debugger: mingw32-w64-gdb
Qt Profile: Qt 4.8.7 mingw-w64 i586
Add one more
Name: Desktop 64
File system name: x86_64
Device Type: Desktop
Device: Local PC
Sysroot: - leave blank
Compiler: MinGW64-W64
Debugger: mingw64-w64-gdb
Qt profile: Qt 4.8.7 mingw-w64 h86_64
we keep, we apply, we try to collect something.

That's probably all that I remembered on this topic.

By the way, a small hack: if you need to slightly reconfigure an already assembled assembly, for example openssl, for example, you decide to add a plug-in or to which muscle you are not going to, and wait 2-3-4 hours until everything recompiles never smiles, do this: set the system time 10-15 minutes earlier than the last time we configured the assembly, reconfigure, return the time to the present. Notepad we change that (those) makefile (s) that (e) affects (they) our changes and run make-up, if you are not mistaken with makefiles (in fact, if you know what Qt consists of and what depends on, it is difficult to make a mistake) only the piece that we need.

Source: https://habr.com/ru/post/367163/


All Articles