Installed Mingw64 But Cannot Compile 64bit Code - c++

I installed Mingw 64 on Windows 8 64bit.
There is the return after i type g++ -v
C:\Users\Hobo>g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/Program\ Files\ (x86)/mingw-w64/i686-4.9.2-posix-dwarf-rt_v4-re
v2/mingw32/bin/../libexec/gcc/i686-w64-mingw32/4.9.2/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: ../../../src/gcc-4.9.2/configure --host=i686-w64-mingw32 --build=i686
-w64-mingw32 --target=i686-w64-mingw32 --prefix=/mingw32 --with-sysroot=/c/mingw492/i6
86-492-posix-dwarf-rt_v4-rev2/mingw32 --with-gxx-include-dir=/mingw32/i686-w64-mingw32
/include/c++ --enable-shared --enable-static --disable-multilib --enable-languages=ada
,c,c++,fortran,objc,obj-c++,lto --enable-libstdcxx-time=yes --enable-threads=posix --e
nable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=rele
ase --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-sjl
j-exceptions --with-dwarf2 --disable-isl-version-check --disable-cloog-version-check -
-disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --
disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as
--with-gnu-ld --with-arch=i686 --with-tune=generic --with-libiconv --with-system-zlib
--with-gmp=/c/mingw492/prerequisites/i686-w64-mingw32-static --with-mpfr=/c/mingw492/p
rerequisites/i686-w64-mingw32-static --with-mpc=/c/mingw492/prerequisites/i686-w64-min
gw32-static --with-isl=/c/mingw492/prerequisites/i686-w64-mingw32-static --with-cloog=
/c/mingw492/prerequisites/i686-w64-mingw32-static --enable-cloog-backend=isl --with-pk
gversion='i686-posix-dwarf-rev2, Built by MinGW-W64 project' --with-bugurl=http://sour
ceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/c/mingw492/i686-492-posix-dwarf-rt
_v4-rev2/mingw32/opt/include -I/c/mingw492/prerequisites/i686-zlib-static/include -I/c
/mingw492/prerequisites/i686-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/c/ming
w492/i686-492-posix-dwarf-rt_v4-rev2/mingw32/opt/include -I/c/mingw492/prerequisites/i
686-zlib-static/include -I/c/mingw492/prerequisites/i686-w64-mingw32-static/include' C
PPFLAGS= LDFLAGS='-pipe -L/c/mingw492/i686-492-posix-dwarf-rt_v4-rev2/mingw32/opt/lib
-L/c/mingw492/prerequisites/i686-zlib-static/lib -L/c/mingw492/prerequisites/i686-w64-
mingw32-static/lib -Wl,--large-address-aware'
Thread model: posix
gcc version 4.9.2 (i686-posix-dwarf-rev2, Built by MinGW-W64 project)
then i use g++ x.cpp -m64
the return is sorry, unimplemented: 64-bit mode not compiled in
what can i do?

Related

g++ 12.1.0 (x86_64-w64-mingw32) shows wrong line numers on compiler error

Ive upgraded my gcc on windows with msys2 and now I get wrong line numbers on compiler errors.
Compiling
1 | int main() {
2 | auto i;
3 | return 0;
4 | }
with
g++ main.cpp -o main.exe -g
results in
main.cpp: In function 'int main()':
main.cpp:6:3: error: declaration of 'auto i' has no initializer
6 | }
| ^
when clearly the error should be at line 2.
Calling g++ -v gives
$ g++ -v
Using built-in specs.
COLLECT_GCC=D:\msys64\mingw64\bin\g++.exe
COLLECT_LTO_WRAPPER=D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-12.1.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/include --libexecdir=/mingw64/lib --enable-bootstrap --enable-checking=release --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --disable-libstdcxx-pch --enable-lto --enable-libgomp --disable-multilib --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev3, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --disable-libstdcxx-debug --with-boot-ldflags=-static-libstdc++ --with-stage1-ldflags=-static-libstdc++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.1.0 (Rev3, Built by MSYS2 project)
Is this a bug in the 12.1.0 version of gcc?

C++ and Go <thread> header is Throwing an Error

Afer reading How To Use C++ In Go, I started to need threads in my c++ programs. Recently when i tried using it it gave me this compiler error:
error: 'thread' was not declared in this scope
thread parsed(parser, var["ExpAct"], calc_params, sendVars, dir, true, line, false);
^~~~~~
parser/parser.hpp:299:17: note: 'std::thread' is defined in header '<thread>'; did you forget to '#include <thread>'?
parser/parser.hpp:17:1:
+#include <thread>
using namespace std;
parser/parser.hpp:299:17:
but I am include the <thread> library in my code. I am using mingw-64 and when I run gcc -v I get
Using built-in specs.
COLLECT_GCC=C:\Program Files\mingw-w64\x86_64-8.1.0-win32-seh-rt_v6-rev0\mingw64\bin\gcc.exe
COLLECT_LTO_WRAPPER=C:/Program\ Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-8.1.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw810/x86_64-810-win32-seh-rt_v6-rev0/mingw64 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=win32 --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-win32-seh-rev0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-win32-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-win32-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw810/x86_64-810-win32-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw810/x86_64-810-win32-seh-rt_v6-rev0/mingw64/opt/lib -L/c/mingw810/prerequisites/x86_64-zlib-static/lib -L/c/mingw810/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: win32
gcc version 8.1.0 (x86_64-win32-seh-rev0, Built by MinGW-W64 project)
I found the solution to my problem. It was not a cgo issue, but rather an installation issue. Instead of selecting posix style threads, i installed win32 threads. This style does not allow for multithreading. To fix this, I re-installed mingw-w64 with posix threads.

Cygwin warning command

I am using Cygwin to compile c++ programs, but I need to know what command do I use to show warnings when there is no endline or new line in the program. I tried using commands like -Wall, -Pedantic, etc but nothing shows up.
Below is the current cygwin I am using.
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with: /cygdrive/i/szsz/tmpp/gcc/gcc-7.3.0-2.x86_64/src/gcc-7.3.0/configure --srcdir=/cygdrive/i/szsz/tmpp/gcc/gcc-7.3.0-2.x86_64/src/gcc-7.3.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libcilkrts --enable-libgomp --enable-libitm --enable-libquadmath --enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts
Thread model: posix
gcc version 7.3.0 (GCC)
This is an improvement made by GCC people for portability, gcc 4.3 onwards. There is no way to get this warning back.
See Here: gcc 4.3 no longer warns about missing newlines at end of files

Sorry, unimplemented: 64 bit mode not compiled in

This is what I'm trying to do(on Windows 7 64-bits):
g++ -m64 -o main main.cpp
And the error I get is:
Sorry, unimplemented: 64 bit mode not compiled in ...
I installed mingw-64-install.exe from here: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/
But I still get the same error. Do I also need to add the path to this folder in the environment variable?
This is what I get when I type g++ -v:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.9.3/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-4.9.3/configure --build=x86_64-pc-linux-gnu --host=m
ingw32 --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i58
6 --enable-languages=c,c++,objc,obj-c++,fortran,ada --enable-static --enable-sha
red --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable- version-sp
ecific-runtime-libs --enable-libstdcxx-debug --with-tune=generic --enable-nls
Thread model: win32​
gcc version 4.9.3 <GCC>
When running mingw-64-install.exe, you have to choose the x86_64 architecture on the settings screen. With this architecture, 64-bit is also the default target. If you run g++ -v, you should get something like:
C:\>g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/Program\ Files/mingw-w64/x86_64-5.3.0-posix-seh-rt_v4-rev0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/5.3.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-5.3.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw530/x86_64-530-posix-seh-rt_v4-rev0/mingw64 --with-gxx-include-dir=/mingw64/x86_64-w64-mingw32/include/c++ --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-isl-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw530/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw530/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw530/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw530/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-seh-rev0, Built by MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/c/mingw530/x86_64-530-posix-seh-rt_v4-rev0/mingw64/opt/include -I/c/mingw530/prerequisites/x86_64-zlib-static/include -I/c/mingw530/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/c/mingw530/x86_64-530-posix-seh-rt_v4-rev0/mingw64/opt/include -I/c/mingw530/prerequisites/x86_64-zlib-static/include -I/c/mingw530/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe -L/c/mingw530/x86_64-530-posix-seh-rt_v4-rev0/mingw64/opt/lib -L/c/mingw530/prerequisites/x86_64-zlib-static/lib -L/c/mingw530/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 5.3.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)
The Target line should say x86_64.
Had this problem with Windows 10 Home / AMD Ryzen 5 3400G.
For some reason the mingw64 install program decided for host i686-8.1.0-win32-dwarf-rt_v6-rev0
Solution was copying the mingw64 x86_64-w64-mingw32 installation from another notebook.

GCC -v returns GCC 4.7.3 even though I unpacked 4.8.1?

so I went to this link Source Forge MinGW to download and install MinGW 4.8.1. (rev 5). I unpack it into C:\MinGW\mingw32. So I open command prompt (win 32 system) and run gcc -v and I get GCC is 4.7.3. This is the full output of gcc -v:
C:\MinGW\mingw32>gcc -v Using built-in specs. COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-cygwin/4.7.3/lto-wrapper.exe
Target: i686-pc-cygwin Configured with:
/cygdrive/i/szsz/git/cygwin-ports-gcc/gcc-4.7.3-1/src/gcc-4.7.3
/configure
--srcdir=/cygdrive/i/szsz/git/cygwin-ports-gcc/gcc-4.7.3-1/src/gcc-4.
7.3 --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --lib execdir=/usr/lib --datadir=/usr/share --localstatedir=/var --sysconfdir=/etc --d atarootdir=/usr/share --docdir=/usr/share/doc/gcc -C --build=i686-pc-cygwin --ho st=i686-pc-cygwin --target=i686-pc-cygwin --without-libiconv-prefix
--without-li bintl-prefix --enable-shared --enable-shared-libgcc --enable-static --enable-ver sion-specific-runtime-libs --enable-bootstrap --disable-__cxa_atexit --with-dwar f2 --with-arch=i686 --with-tune=generic --disable-sjlj-exceptions --enable-langu ages=ada,c,c++,fortran,java,lto,objc,obj-c++ --enable-graphite --enable-threads= posix --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmat h-support --enable-libssp --enable-libada --enable-libjava --enable-libgcj-subli bs --disable-java-awt --disable-symvers
--with-ecj-jar=/usr/share/java/ecj.jar -
-with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-ppl --with-sy stem-zlib : (reconfigured) /cygdrive/i/szsz/git/cygwin-ports-gcc/gcc-4.7.3-1/src
/gcc-4.7.3/configure
--srcdir=/cygdrive/i/szsz/git/cygwin-ports-gcc/gcc-4.7.3-1/ src/gcc-4.7.3 --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin
--sbindir=/usr/ sbin --libexecdir=/usr/lib --datadir=/usr/share --localstatedir=/var --sysconfdi r=/etc --datarootdir=/usr/share --docdir=/usr/share/doc/gcc -C --build=i686-pc-c ygwin --host=i686-pc-cygwin --target=i686-pc-cygwin --without-libiconv-prefix -- without-libintl-prefix --enable-shared --enable-shared-libgcc --enable-static -- enable-version-specific-runtime-libs --enable-bootstrap
--disable-__cxa_atexit -
-with-dwarf2 --with-arch=i686 --with-tune=generic --disable-sjlj-exceptions --en able-languages=ada,c,c++,fortran,java,lto,objc,obj-c++
--enable-graphite --enabl e-threads=posix --enable-libgomp --disable-libitm --enable-libquadmath --enable- libquadmath-support --enable-libssp --enable-libada --enable-libjava --enable-li bgcj-sublibs --disable-java-awt --disable-symvers
--with-ecj-jar=/usr/share/java /ecj.jar --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-ppl --with-system-zlib Thread model: posix gcc version 4.7.3 (GCC)
C:\MinGW\mingw32>
I would like to know why it unpacked an earlier version and how to fix this. Apparently C::B see's it as an earlier build too! It really baffles me O.o
Also, the prompt returns that threads use Posix when it should be Win32, again really rattling my brain here.
If any one can point to some links, or clear any of this up it would be greatly appreciated!
What you unpacked, and what the OS presents when you call the program, need not be the same thing. Did you do a rehash? Confirm that the path is the same? Or is the new version at a later point in the path? You might want to alias the gcc command to the version you want. Type which gcc to see where the OS thinks the "current version" is located - that should help. EDIT I realize the which command may not work in windows (just noticed the C: drive letter) but the main point about paths is still valid.