Reputation: 15
I use the Dev-Cpp program with the MinGW compiler that allows you to compile C / C ++ code to obtain a Windows launcher, but is there a compiler for Windows that allows you to create executables for Linux?
Upvotes: 1
Views: 596
Reputation: 101
Ignoring the fact that Dev-C++ has been obsolete for nearly a decade (I may have an unpopular opinion however that you should use whatever tools you can to learn whatever you can, even if that means using 'obsolete software' [as long as it's purely for learning and not production use])...
You have a couple options, one of which has been mentioned by somebody. 1.) Use a cross-compiler, and 2.) (which I personally would recommend, if it is viable for your particular needs) simply compile on actual Linux.
To do this, you just need a working distribution of Linux with a development environment. You can use a virtual machine, Windows Subsystem for Linux (WSL), or a physical machine with Linux running on it.
From there, if you want the code to compile for multiple operating systems, you'll have to make sure your libraries and frameworks and other OS-specific code (e.g., filesystem paths, system calls) are properly handled, or just use cross-platform libraries. If you're dealing with standard C/C++, then this won't be of any concern.
Since Dev-C++ uses MinGW (the Windows port of GCC), then the actual compilation process should be the same, although on Linux IDEs are not commonly used, so you may have to get your hands dirty with shell commands, but that's not too hard once you get started. Good luck!
Upvotes: 1
Reputation: 113
You can install Windows Subsystem for Linux, or set up a VM and do it that way.
Or as @user4581301 mentioned, use a cross-compiler.
http://metamod-p.sourceforge.net/cross-compiling.on.windows.for.linux.html
Upvotes: 2