C++ learning-1 (various compilers, and qmake under qt, cmake, cmake management under linux)

1. Basic C++
1. Both g++ and gcc come with the ubuntu system and are a set, so many uses are the same.
2. g++ -v to view the C++ compiler version number, you can view
x86_64-linux-gnu
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11)
We are using Ubuntu version 16,04, the x86 version of gcc compiled version is 5.4.3
, -std=c++xx specifies the compile time used C++ Standard The
version of the gcc compiler we currently use supports many C++ standards. Remember that these are two things.
g++ hello.cpp -std=C++11 means that we use the C++11 standard to compile this file.
You can use the man manual man g++ for related viewing.
4. C++ has different compilation chains on different platforms. MSVC MinGW GNU (gcc g++) Clang
MSVC is provided by Microsoft and needs to be combined with some Microsoft libraries to use it.
MinGW is actually under Linux GNU is also a layer of g++ encapsulation, which can be used under windows, and this is used in qt

Two; QT introduction and installation
Download official website; http://download.qt.io/official_releases
1. Kits (build kits) are required for the complete operation of qtcreator, including compilers, debuggers, project managers, etc.;
a pure qt software is not To use, a complete set of build kits are needed to complete the compilation of the program, but choosing a different build kit can complete the compilation of the same program to generate executable programs for different platforms. This is also qt cross-platform, and java cross-platform is compiled and can be used directly in the java environment. It is a little different from qt.
2. The build based on qtcreator can be built independently or as a whole at one time. We can choose the integrated qt software, which is different from manual installation for so long, but because of the cross-compilation tool chain involved in the embedded development process, and the compiled executable program needs to be run on different special platforms, this requires To build the kit by yourself, others cannot have the qt software of the integrated kit.
PS; if there is no skip in the second step of the installation, you can disconnect the network first and then connect after that step.
3. It is best to select all at one time when installing and selecting the package, because subsequent additions are not supported unless deleted and restarted.
In Developer and Designer Tools;
select the debug bridge suite, and the 64-bit or 23-bit MinGW compiler version, and select the corresponding supporting tools on QT. The selected sources can also be the source code of QT, and you can view some things.
PS; you can turn off the firewall software when installing, because some things will be prohibited.
4. The installation of qt under linux is also the same, as long as you go to the official website to download linux, you can execute it with the run suffix, and you can execute it directly under linux.
5. Compile and execute qmake and cmake.
Insert picture description here
Insert picture description here

3. CMake
MakeFile manages and compiles complex projects to facilitate the compilation and linking process, but its syntax is too obscure, and we can only understand and modify it. If it is necessary to write it out, it is still difficult, so Cmake appears. Lightweight based on MakeFile.
Cmake is actually a layer of encapsulation on the Makefile, which provides a relatively simple syntax, we write and compile Cmake will automatically generate a matching Makefile without us having to write a MakeFile file with obscure syntax.

Installation of cmake;
download the official website; https://cmake.org/download/ download the source code
After decompression,
install: execute ./bootstrap; if the installation fails, the installation of the OpenSSL library is generally required according to the prompt statement. Please note that you may need permissions during installation. If you cannot solve it with sudo, it means that the steps of installing the library do not support sudo. You need to switch to the root directory to install, and then remember to return to the current user name. Because the variable installed in the library is bound to the user name.
https://blog.csdn.net/weixin_34072159/article/details/86028584
Make it;
then Cmake --Version to check if the installation is successful

Initial use of cmake
(1) File name: CMakeLists.txt (must be named this)
(2) Content example:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
#Minimum version requirement SET(CMAKE_CXX_COMPILER “g++”) #Set g++ compiler
PROJECT(Hello) #Set project name
MESSAGE(STATUS “test project hello world”)
#Print message ADD_EXECUTABLE(hello hello.cpp) #Generate executable file

actual
Insert picture description here

Some tool links
Link: https://pan.baidu.com/s/1xgjxJsg9m4yLfAapTFpBxg
Extraction code: oq96
Copy this content and open Baidu Netdisk mobile phone App, the operation is more convenient.

Guess you like

Origin blog.csdn.net/zw1996/article/details/105178639