I'm a C++ new learner and want to set my PC to learn coding. But the compiler doesn't work after all the MinGW packages were installed, and it doesn't show what goes wrong. How can I get it work?
I'm using Windows 10 (64 Bit).
All the MinGW packages were installed: enter image description here
The Path was setted: enter image description here
Use g++ -v to test, it's Ok, on the cmd it shows:
C:\Users\shaun\Documents\cpp>g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe Target: mingw32 Configured with: ../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --with-gmp=/mingw --with-mpfr=/mingw --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --with-tune=generic --enable-libgomp --disable-libvtv --enable-nls Thread model: win32 gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)
But it doesn't work: C:\Users\shaun\Documents\cpp>g++ 1.cpp
C:\Users\shaun\Documents\cpp>g++ 2.cpp
C:\Users\shaun\Documents\cpp>
1.cpp is just a HelloWorld:
#include <iostream>
int main()
{
std::cout << "Hello, World!";
return 0;
}
2.cpp is a simple loop:
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n ;
cout<<"please input the height"<<endl;
cin >> n;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n - i -1; j++)
{
cout<<" ";
}
for (int j = 0; j <= 2 * i; j++)
{
if (j == 0 or j == 2 * i)
cout<<"*";
else
cout<<" ";
}
cout<<endl;
}
for (int i = 0; i < n - 1; i++)
{
for (int j = 0; j <= i; j++)
{
cout<<" ";
}
for (int j = 0; j <= 2 * ( n - i - 2 ); j++)
{
if (j == 0 or j == 2 * ( n - i - 2 ))
cout<<"*";
else
cout<<" ";
}
cout<<endl;
}
return 0;
}
a.exe
file generated? What if you list all files in the directory after building? – Some programmer dudeg++ 1.cpp
simply creates the program. You then need to actually run it. – Galik