youtube视频教程:
1. install mingw-64 on windows
1.1 download mingw-64
goto download link to download the install program: mingw-w64-install
or download the mingW version x86_64-win32-seh
1.2 extracted the 7z compressed file to a foler using 7z
1.3 add the bin folder of mingw-64 to Windows PATH environment variable.
open a new Command Prompt and type:
g++ --version
gdb --version
1.4 compile and run a c++ program
use notepad++ or notepad to edit a file “hello.cpp” as following:
#include <array>
#include <iostream>
#include <string_view>
#include <tuple>
#include <type_traits>
namespace a::b::c
{
inline constexpr std::string_view str{ "hello" };
}
template <class... T>
std::tuple<std::size_t, std::common_type_t<T...>> sum(T... args)
{
return { sizeof...(T), (args + ...) };
}
int main()
{
auto [iNumbers, iSum]{ sum(1, 2, 3) };
std::cout << a::b::c::str << ' ' << iNumbers << ' ' << iSum << '\n';
std::array arr{ 1, 2, 3 };
std::cout << std::size(arr) << '\n';
return 0;
}
in new Command Prompt and type:
g++ -std==c++17 hello.cpp -o hello.exe
hello.exe
2. cofigure CodeBlocks for mingW-64 C++ compiler
from the main menu to select “Settings → Compiler →Toolchain executables.
change from
to
from the main menu to select “Settings → Compiler →compiler setting. click the “compiler flag” and check the box “Have g++ follow the coming -std=c++1z (aka C++17) ISO C++ language standard…”
Alternatively, you can go to the Other Compiler Options tab and type in -std=c++17.
##
https://code.visualstudio.com/
Refer to
- https://code.visualstudio.com/docs/cpp/config-mingw
- Install Code::Blocks and GCC 9 on Windows - Build C, C++ and Fortran programs
- https://www.learncpp.com/cpp-tutorial/configuring-your-compiler-choosing-a-language-standard/
您的打赏是对我最大的鼓励!