I have 2 sets of C++ files, one set which I only have the .o files from GCC but no source code, while the other set in Microsoft Visual Studio 2015 which I have the full source code - this set includes various VS libraries such as the Windows SDK. For deployment I would prefer to have one single EXE only (no DLLs), so I would like to link the .o files to the .obj files generated by Microsoft Visual Studio. The .o format seems incompatible with the .obj format, neither one can be converted to the other, and no linker seems to be capable of linking these two types of files together to produce 1 single EXE. Hence, my only option is to compile the set of files under Microsoft VS into .o format. I tried using GCC but even after quite some modifications to the Microsoft library source codes GCC still won't compile - there are a lot of C++ templates that the GCC compiler rejects. This would be too difficult for me to figure out how to modify.
(Edit: statement above seems not completely correct, I missed this earlier, Stack Overflow suggested to me, .o files and .obj files can be converted between them although I have yet to test out the tools and would need more research to determine how reliable this approach is: Converting C++ object file from linux .o to Windows .obj. I believe the .o files from GCC in Windows are the same as those it generates in Linux. Also, I was not clearer earlier, that although the files are C++, the intercommunication between the 2 sets, the VS set and the non-VS set, only needs to be done in C code i.e. .obj will communicate with .obj files in C++ but will communicate with .o files only using C calls. Still, given this approach seems not widely used, I would still prefer compiling VS source files with GCC since as long as I understand the modifications needed for the source files, I can be confident that the end result is reliable.)
I looked into Clang to compile to .o, but the Clang websites seems to indicate that it cannot compile all of the Microsoft Windows libraries either: http://llvm.org/docs/GettingStartedVS.html
I looked into the Intel C++ compiler too, which can compile Microsoft libraries, but I couldn't figure out how to make it output .o instead of .obj under Windows.
Are there any guides on how to modify the Microsoft libraries (included in VS2015) to be compiled under GCC/Clang? The closest I have found online is this: http://www.transmissionzero.co.uk/computing/win32-apps-with-mingw/, which I tested to work on MinGW, but it uses MinGW's own set of (modified?) Windows libraries which excludes all of the ATL files.
(Edit: after exploring a bit more, not 100% sure but quite convinced GCC probably cannot compile MS VS libraries, might just have to wait for a later version of Clang instead. Syntax issues can be fixed, like changing i64 suffixes to LL, getting rid of throw(...) in function declarations, etc., but things like __ptr32, __ptr64, __vectorcall, missing in GCC, not really sure if can be just dummy-ed out, and things like __getcallerseflags seems quite likely no simple workaround, if at all possible. Pasting my GCC command line switches here in case anyone wants to try: -std="gnu++14" -nostdinc -Wmissing-include-dirs -fpermissive -fms-extensions -D "__ptr64 =" -D "__ptr32 =" -D "__vectorcall = __fastcall" -D "__unaligned = " -D "__forceinline = inline" -D "__nullptr = nullptr" -D "__pragstr(X) = _Pragma( #X )" -D "__pragma(X) = __pragstr(X)" -D _M_AMD64 -D _M_X64 -D _WIN64 -D "_MSC_VER = 1400" -D "__int64 = long long" -D _WINSOCK_DEPRECATED_NO_WARNINGS .... -I include the MS VS folders)