I'm trying to determine if it is possible to use MinGW to compile code that requires Microsoft Foundation Classes (MFC) or Active Templace Libraries (ATL), libraries that come with Microsoft Visual C++ (MSVC).
Some context: My end goal is to be able to generate gcov
reports on Windows for a C++ tool. The code contains many codepaths which will only be reached if built on Windows (i.e. section guarded by #ifdef _WIN64
). This means I need to build an .exe
with gcc
. The reason I want to do this? I'd like to get a more complete code coverage result by running tests on Windows so that these codepaths can be tested for coverage as well. Is this viable in anyway?
This is what I've tried. Starting small, I've been trying to get this program to build using MinGW
on Windows:
#include <iostream>
#include <atlstr.h>
int main() {
CString aCString = CString(_T("A string"));
_tprintf(_T("%s"), (LPCTSTR)aCString);
}
This compiles with MSVC with no hassle. Now, with MinGW: To build I just call gcc -fprofile-arcs -ftest-coverage test.cpp -o test
. However, it fails with the following message:
test.cpp:3:10: fatal error: atlstr.h: No such file or directory
#include <atlstr.h>
^~~~~~~~~~
compilation terminated.
This is expected of course. I found all the ATL
, including atlstr.h
, in C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\atlmfc\include
, and copied that all to one of the directories MinGW
looks for includes. This time it found the header files but a huge list of errors came up which I probably shouldn't include here.