I'm currently working on pure C++ library in Linux using g++, but from Windows (through VPN). It is very inconvenient because the connection is very slow. I'd like to get library's sources on Windows and use a gcc ported to Windows (e.g. MinGW or CygWin). But I'd like to know to what extent linux gcc compiler is compatible with Windows gcc compiler? Are they built from the same code base?
1 Answers
If you think about language features, gcc
on Windows (Cygwin/MinGW) is compatible with gcc
(of the same version) on Linux as long as you don't use OS features that are not available on the other OS. (This is merely a library issue.) The resulting library created with gcc
for Windows cannot be used on Linux. That means you can use gcc on Windows to get your code working on Windows but have to compile it on Linux to get a library for Linux.
It would be possible to create a library for Linux on Windows if you use a cross compiler for Linux target on a Windows system.
Are you accessing a graphical development environment running on Linux over VPN? Maybe you can run a development environment on Windows with remote compiling and debugging, see https://stackoverflow.com/a/4216878/10622916 for a solution with Eclipse. This might be better suited for a slow connection.
GCC for different platforms is built (mainly) from the same source, see e.g. https://gcc.gnu.org/gcc-8/buildstat.html Of course the source contains both platform specific and target specific code parts, so it's not completetly the same source code.

- 9,287
- 1
- 13
- 29
-
Thank you! But do you know whether the ported gcc is built from the same sources as original gcc? – embedc Jan 29 '19 at 09:26
-
it is built from same source, plus some specific patches – matzeri Jan 29 '19 at 18:17