Which Windows compilers support <future> class - c++

I was trying to run the test code for the future class on Windows but I had several problems. First I tried using the default compiler of Code::Blocks which in my case is MinGW 4.7.1 obtaining the error
error: variable 'std::future<bool> fut' has initializer but incomplete type|
As suggested in this question it seems that
No one has provided the necessary code to make the C++11 thread features work on Windows yet.
Since the question was from 2012 I gave it a try with more recent compilers. I had no luck using both MinGW 4.8.1 and MinGW 5.1
Surprisingly, when I tried the default compiler for Qt Creator which in my case is MinGW 4.9.1 it worked fine.
How is this possible?

MinGW != MinGW
Multiple GCC-for-Windows projects exist, like MinGW, MinGW and MinGW, with different development states (last one supports the most).
Future objects are part of concurrency which got attention in GCC 4.8 and MSVC 11.
C::B uses TDM-GCC, QT Creator MinGW64 - that's the point.

Related

MinGW - Header incomplete <netfw.h>

i am developing a networked application in C++ that should be able to add a rule to the windows firewall. I am following this example using the MingW g++ compiler.
The other examples are working without a problem, but this particular example won't work.
The exact problem i am facing, that NetFwRule is not defined in the <netfw.h> header provided by MinGW. When i try to compile that example with MSVC (in Visual Studio) it works flawlessly, since NetFwRule is defined in the header provided by MSVS. However it is absolutely neccessary for the project to use the MinGW g++ compiler.
This particular code snippet as shown in the example link won't work, since NetFwRule is not defined:
// Create a new Firewall Rule object.
hr = CoCreateInstance(
__uuidof(NetFwRule), // <- Problem in MinGW g++, but in MSVC it just works
NULL,
CLSCTX_INPROC_SERVER,
__uuidof(INetFwRule),
(void**)&pFwRule
);
So what needs to be done in order to make this work using MinGW?
FYI: I have MinGW 32 bit with posix thread for the i686 architecture installed.
g++ --version gives g++ (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 8.1.0
The error message is: 'NetFwRule' was not declared in this scope
In fact it really is not declared, since the <netfw.h> of MinGW does not declare NetFwRule. MSVC however does.
Your GCC was too old.
You can get a newer version via MSYS' pacman, or download a standalone build, for example from http://winlibs.com/ which will work just as well if you don't need MSYS2.
Okay, I have tried to use MinGW 64 bit just as IInspectable suggested, but that does not work either - the netfw.h header still does not provide NetFwRule. However i have installed g++ along with MSYS2 (the version that rustyx is using), which just works as expected. So if anyone faces the same issue I would suggest to use MinGW along with MSYS2 and not standalone.

QT enable cross-compiling using MinGW (precompiled)

Good day all
I have been searching for a method of cross-compiling for QT-Creator in Linux for sometime now, and I have been having alot of trouble with it.
Background info
please note: I am on a Linux machine, and would like to cross compile Windows Apps
My system:
Ubuntu Gnome 16.10
QT Creator 4.0.2 (based on QT 5.7)
I have came across a few SO links, a few blogs with broken instructions, etc and one seeming helpful but dependencies could not be found.
I have also attempted another compiler MXE and cloned and attempted to build the MXE compiler from the GIT repo, which failed (no solution for the build error - VTK build error)
I decided to download precompiled MinGW compilers (i686 and x86_x64 versions) from sourceforge
Issue:
In QT Creator, adding the compiler is done without an issue, adding the "Kit" and selecting the newly added compiler, an red exclamation gives an error
The Compiler (x86_windows_msys_pe_64bit) cannot produce code for QT version 5.7.0 GCC 64Bit (x86_linux_generic_elf_64bit)
This occurs for both 32 + 64 bit compilers.
I think that you should have a QT version that matches your compiler ABI. The error tells you that the MinGW compiler doesn't match the Linux version of QT you have used. Therefore, get a windows version of QT and use it instead (just as you've added WinGW).
You can download Qt Binaries from here.

Why does mingw-w64 support strcpy_s() while tdm-gcc fails compiling that call?

I'm trying to compile an open source library from bitbucket for various platforms. Compiling for Windows works only using the mingw-w64/32 4.8 compiler. Other compilers like tdm-gcc 5.1 fail at those lines calling "strcpy_s", stating they are not defined in this scope. On Linux, compiling works without a problem using the standard gcc on Ubuntu 16.04. I'm aware of the workaround to replace the (c++ 11) strcpy_s with std::strcpy.
I don't understand why this is happening because the tdm-gcc is even more up to date than the mingw-w64 version.

Get Eclipse (version 3.8) to use C++11 for Ubuntu 15.10

I get these two errors, when trying to initialize a vector with
std::vector im = {i,j,k};
Errors:
could not convert ‘{i, j, k}’ from ‘’ to ‘std::vector’
C++98 ‘im’ must be initialized by constructor, not by ‘{...}’
I think the problem is, that Eclipse is not using the C++11 libraries. I have tried to get Eclipse to use them as suggested on here (Eclipse CDT C++11/C++0x support), but it still does not work.
I am running Ubuntu 15.10 with the g++ version 5.2.1 20151010.
Thanks :)!
EDIT: I am just a bit clumsy, added the flag in the wrong tab... Working now!
You can update the compiler flags as suggested, but Eclipse C++ support has evolved very much from version to 3.8 to version 4.5, the current stable one. So by updating Eclipse you will also get better code hinting and completion in the editor and even support for the latest C++14 features.

Xcode tools on Mac support c++11?

I do most of my coding using Qt in C++ and have noticed that I get x86 architecture not found errors when I enable support for C++11 in my Qt .pro files.
I have the latest Ver of Xcode and have developer tools installed. I realize that OSX uses clang but it still seems that I am still stuck with OSX only supporting earlier versions of gcc.
Is there a reason we can't get these updates from Xcode, and if not I guess I need to install these updates myself?
You can use clang with this FLAGS -std=c++11 -stdlib=libc++ to use C++11 features, another similar question can be found here