Is it possible to compile a windows .exe program using g++?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is it possible to compile a windows .exe program using g++?
I have to write a few programs in c++ for my course. My machine is a linux machine, but the computers we use for the course are all windows machines. I usually compile my projects by sending them in, then compiling them using bcc, but it would be much easier if there were a way to compile them in linux, for example, though not essentially, with g++.
I don't know how to do that from Linux; you can create C++ that is *compilable* (is that a word?) on Windows but not create a windows binary, AKAIK. You'd need to have all the Windows libraries and such installed. (possible with WINE?)
However, you can use Cygwin's version of g++ on Windows to build a Windows binary, and I think there's a "-fno-cygwin" (or something similar) flag which will make it not depend on the cygwin dll. This helps you because your code will probably be easier to port from g++/linux to g++/cygwin than from g++/linux to bcc/windows.
Sure, you can do it with mingw check http://www.mingw.org/index.shtml . But its a little bit hard since you need to try it running wine, and wine has some bugs (Finally you don't know, is it a bug from wine, my app, both).
If the C++ programs in question aren't making use of Windows-specific function calls and libraries, then it should be fairly easy to port them over after you've written them. I've done course work this way - just get them working in Linux using your g++ compiler, then give yourself a couple days after it's done to go use a Windows machine to compile them and work out any new problems. Most command-line C++ programs that do normal I/O (cout, cin, etc.) should be no problem; if you're doing stuff with graphics, MSFC, or anything else that would rely on a Windows library, it'd probably be trickier...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.