GCC on Windows OS - gcc

I was wondering is there a free Windows version of GCC.
I know there is minigw and something else but I don't know how to use them.
Sorry if this should be on SU.

The main choices are either MinGW or CygWin.
CygWin is a more complete UNIX-like environment than MinGW as it offers quite a lot of tools over and above development stuff. Even to the point of a full X-Windows server so you can develop software that'll run on both UNIX-like systems and Windows.
The installer is good but I would suggest installing everything even if you think you don't need it. Disk space is cheap and I've had problems in the past trying to get stuff going on partial installs (whether 1.7, or even earlier, fixes this, I don't know - I always do full installs).
However, it relies on the CygWin UNIX emulation DLL which, if I remember rightly, has restrictions for non-free software.
MinGW is more concentrated on the development tools. It generates native Windows applications rather than running under a emulation DLL like CygWin.
It used to be difficult to install with having to do MinGW, MSYS and others separately but it's come a long since then and has an easy graphical installer.
I believe it can do graphical applications using native Windows calls rather than via X-Windows, since it just links to the normal Windows runtimes.
If you want to know how to use either of them, you really have to look through the docs found at those links I provided - check the Documentation link on the left for MinGW (particularly Getting started) or the CygWin FAQ.
As for GUIs for development, I've never used one for CygWin - I'm old enough that I remember mark sense cards so I'm not scared of the command line interface :-).
I used Eclipse with CDT running over MinGW and wasn't that impressed although admittedly that was an early version. Don't get me wrong Eclipse is a brilliant tool and we use it for both Java and Linux/C development, I just had a lot of troubles with Eclipse/CDT under Windows.
Code::Blocks, on the other hand, was absolutely brilliant but you should check them all out to see which one suits you best. As I said, the last time I looked was about five years ago, an eternity in the IT world.

I am a bit late, but since the question may still arise...
gcc for Windows (including Ada, C, C++ and Fortran compilers) can be obtained from MinGW-builds on SourceForge: http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/
As of august 2013, there are 32 and 64 bits versions of gcc-4.8.1.

Related

IDE use a VM compiler?

I'm starting to work on my master thesis at the moment and I have a (maybe) specific question...
I want to stay on windows OS and run a Linux VM via VirtualBox combined with Vagrant. No Problem. I like the feature to reset the VM via vagrant easily.
The next target is using features like auto-completing or similar while developing in C++. This would help me to work with unknown includes/libraries.
Is it possible to access the filesystem/compiler of the VM while using an IDE (like clion) installed on windows? Without explicit loading of the gui und running the IDE on it? Kinda like working with cygwin? I don't want to use cygwin because it doesn't support c++11 standard (or is there a way???)
Maybe you know an alternative way. I would be glad for all hints solving my problem.
I don't know much about cygwin, though I would be surprised if they cannot get recent versions of gcc. But for certain, you can use MSYS2 to get very recent versions of gcc and many other linux packages, which will support C++11.
It's a matter of opinion how best to do cross-platform development, but an alternative worth mentioning is to use cmake for your project. When you want to code in windows, it can make MSVC 2015 project files for you -- when you want to compile in linux, it can find the dependencies and generate a makefile for you to use. IIUC, cmake is the most widely used cross-platform build system right now, besides gnu make itself. (I'm pretty sure it's more popular than "autotools" nowadays, and its definitely more popular than scons.) The advantage is that you avoid the need to maintain multiple platform-specific project files that essentially say the same thing with different formatting.

Compiling software in cygwin requires cygwin libraries to run

I have just compiled some software in cygwin and all went well, except when I tried to run it on a different machine it required some cygwin specific libraries .dll's, is there anyway I can build this in with the software so it can run on third party machines without cygwin installed? Im trying to be generic with the question so the answer will suit other people facing the same or similar problem so sorry for the lack of detail on the software etc. (sgminer)
Thanks for any help
Not only is this a duplicate, as Paul R point out, it's also an FAQ on the Cygwin site.
From "How do I compile a Win32 executable that doesn't use Cygwin?"
The compilers provided by the mingw-gcc, mingw64-i686-gcc, and
mingw64-x86_64-gcc packages link against standard Microsoft DLLs
instead of Cygwin. This is desirable for native Windows programs that
don't need a UNIX emulation layer.
This is not to be confused with 'MinGW' (Minimalist GNU for Windows),
which is a completely separate effort. That project's home page is
http://www.mingw.org/index.shtml.

Set up a development environment on Linux targeting Linux and Windows

For a university course I have to write a http server which is supposed to run on both Linux and Windows.
I have got a humble Linux machine which I don't think can handle any kind of heavy virtual environment, neither I'm willing to go through the hassle of installing it.
This is the first project of mine complex enough (I estimate ~1.5 months to develop) to require an environment sufficiently comfortable to alternate rapidly between short coding and testing sessions (the latter on both platforms, of course).
So, I was wondering what could be the best set up for this situation. I think testing it on Wine would be ok (it is not a real-world thing, after all), and I installed MinGW for the Windows-targeting part.
Basically, a simple well-written makefile could solve my problem... It should build both the Linux and Windows binaries and place them in the respective folders (the Windows one in the Wine sub-tree) and I'm all done! But I feel very inexperienced in this thing and I really don't know where to start. Maybe the make manual, ahah!:)
Thoughts, suggestions, anything I didn't think/know!
Thank you!
(PS. I'm planning to use emacs as editor, or maybe learn vim. Unless eclipse provide some kind of skynet-like plugin that entirely solve this problem...:)
You're on the right track. It's not that complicated, really, thanks to MinGW. You basically need two things:
The code has to be portable across the OSes. MinGW has some POSIX support, but you'll probably need to either use Cygwin in order to be able to use the POSIX interface or have your own compatibility layer for interfacing with the OS. I'd probably go for Cygwin as then you can code only against POSIX and won't have to test and debug your compatibility layer. Also, make sure you won't use any external libraries that are OS specific. Non-portable code often results in a compile error, but make sure you test the application thoroughly anyway.
The toolchains for targeting Linux and Windows. You already have them, you just need to use them correctly. Normally you'd use a variable like $(CROSS_COMPILE) as a prefix when calling the toolchain during cross compilation. So when compiling for Linux, you call gcc, ld, etc. (having the CROSS_COMPILE variable empty), and when compiling for Windows you call e.g. i486-mingw32-gcc, i486-mingw32-ld etc., i.e. CROSS_COMPILE=i486-mingw32-. Or just just define CC, LD etc. depending on the target.
I wrote a small game on Linux and made it run on Windows as well. If you browse the code, you can see the code has next to no #ifdef jungle (basically just some extra debugging features enabled for Linux), and the Makefile is simple as well, with no complicated handling for cross-compilation, just the possibility to override CC etc. like it should be. As lots of important open source software is written this way (especially software that's used by the desktop and embedded devices), you should also be able to find lots of other examples on how to set up the build environment correctly.
As for testing the application on Windows, I think the best option is if you can find a real Windows machine somehow. If you do everything correctly, it should run the same as on Linux and you won't need to continuously test your application on both OSes. If testing on a Windows machine is not possible, a VM would be the next best choice, though it would probably be more difficult to set it up. Wine is a good backup plan, but I don't think you can be sure your application works well on Windows if you only tested it on Wine.

Languages that Windows supports out of the box

I have been asked to write a (very) simple program for a set of Windows machines (XP I think) - so simple that the choice of language isn't really an issue. However, I want to be able to distribute a binary/script that will run straight away on the Windows machine, without the need to pre-install any interpretor or virtual machine. I'm developing on a Linux machine and I have no idea what languages Windows supports 'out of the box'. Can anyone advise?
For example
Perl would be great but I don't believe windows machines come with Perl pre-installed? Asking the user to install Perl to use my script is not acceptable.
I believe Python has the same problem? (although maybe I can use the PyInstaller? -- as in this question)
Likewise Java? Is the virtual machine pre-installed on most Windows distributions? (I understand it got removed after a dispute with Sun Microsystems?)
The only option I can think of so far is
c/c++ with MinGW cross-compiler.
While I'm happy to write the code in c++, I wanted to check my language options first.
The only scripting languages supported out of the box are the batch interpreter, vbscript and jscript. Other than that you are into compiled languages. A good option could be C# but make sure you target the .net version that shipped with XP.
Delphi and Lazarus/FreePascal generate native applications that don't even need on MSVCRT
Some of the other systems have requirements on relatively new MSVCRT versions that might be a burden on older windows versions.
However recent Lazarus and Delphi versions stop supporting windows NT4 and Win9x, with win2000 in a gray area (not supported but works afaik)
Having an internal win32/64 linker makes it also an excellent choice for crosscompiling from *nix to Windows.
I don't think that Java comes pre-installed on Windows.
I'm not using Windows for some years now, but if I correctly remember you can develop scripts with VBScript or JScript and deploy them without need for clients to install anything.
Any language which compiled to pure native assembly (without special run-time dependencies) should be fine. For example: many C variations (but not all), Microsoft Visual C++, Microsoft Visual Basic 6, OCaml, Haskell and more.
Requiring the .NET Framework (which gives you also C#, VB.NET and F#) is reasonable, and also JVM is pretty standard (and so you get Java, Closure and Scala).

Development Environment in Windows [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
What are your recommendations for setting up a development environment in Windows, especially when not using an IDE. I am attempting to familiarize myself with Windows, and I feel a bit lost. What do developers commonly work on, especially when developing in multiple languages (e.g. Java, Python, C) in the same time.
So far, I have been a hardline using Mac+Linux environments where I love my command line a lot. I pretty much run all my compilations, testing, code repository commands in the terminal and have multiple terminals all the time. Terminal features (e.g. integrated bash completion, easy copy&paste, easy to setup environment variables) and package management tools (e.g. apt-get, port, fink) are quite handy. I dislike hunting down different websites to install their latest binary build.
Coming back to my question. My question is two fold:
What's commonly used? Do developers on Windows commonly use command line, or just be satisfied with an IDE?
For comers from Linux/Mac world: what do you recommend to get up to speed?
NOTE: I realize that a lot of Windows developers haven't used Linux, so they may not know what I'm talking about when it comes to Linux environment.
It's almost unheard of to not use an IDE for Windows development.
I started programming in the early 80's so grew up on the command line, but nothing beats a modern IDE for productivity.
By far the most common choice is Visual Studio, though I have also used #develop (open source) and find it a fine platform to get up to speed with.
I have used Eclipse extensively (on Linux and Windows) and find Visual Studio to be easier to use. I especially miss options for debugging under windows such as moving the instruction pointer around during debug and change-and-continue (change the code, within limits, while debugging, move the instruction pointer back if necessary, and keep debugging).
If you have used Eclipse, Visual Studio or #develop will not be that hard to get used to.
I tend to install cygwin, which is a unix emulation layer and includes many of the standard unix utilities (grep, awk, sed, etc). You can use bash or any other unix shell with cygwin to basically give yourself a unix environment on windows.
There are some downsides, paths are a good example. Windows programs expect windows paths while the unix tools expect unix paths. You can convert between the two using the cygpath program, but sometimes its tricky to know when to use it.
Another thing I do fairly often is create a bunch of batch files that load different programs onto my path. This allows me to have different version of say java installed and I can pick the version I want to use for any given shell session. I link a bunch of these together so that I have a full environment for the program I'm working on. For example, if I require java 1.5, maven, subversion then I would have a batch file to load each into the environment, then have a master file that loads all of them for a standard environment.
This approach gives a lot of flexibility and is really easy to maintain and work with different environment simultaneously.
Most windows developers that develop on the microsoft stack of products probably use Visual Studio. For windows development without Visual Studio, SharpDevelop is the current most popular alternative.
However if you are looking for a user experience more similar to linux you can always use windows command prompt and all of the command prompt compilers still exist. Just like with linux you'll have to modify your environmental variables to make everything work you you'd like it to.
If that still isn't close enough to the feel on linux, you can try out Cygwin.
Many of your common utilities from linux like gdb do have windows builds as well.
And of course there is the Eclipse IDE that is used for many languages, by many people, on multiple platforms. It is very extendable.
Some other tools you may be missing:
GCC - Available Via Cygwin
MS Build can give you similar functionality to what you had with make (I'm not sure if nmake is still used/supported)
Vi/Vim
Grep
SysInternals will have lots of various file/process monitoring utilities to hopefully adequately replace what you miss being able to simply get from /proc
Wireshark(or ethereal) to replace well... wireshark/ethereal/
Tail is available in the Windows Resource Kit
Emacs
Hopefully that covers most of your basic tasks.
Microsoft now has a real shell for Windows: Windows PowerShell.
In addition to Cygwin, there are ports for a lot of the GNU utilities and toolchain to Windows. GnuWin32 seems to be a more up-to-date version than UnixUtils. MSYS is essentially a port of BASH to Windows, but it's fairly useless without the MinGW userland.
C++ / .NET Development: Visual Studio 2008
Java / PHP Development: Eclipse IDE, which also supports C/C++.
For a non-IDE solution, Notepad++ is a very good code highlighter that supports many languages.
Simply install cygwin. The quality has improved dramatically in recent years. I'm currently running cygwin x64 on Vista, and it's great.
One thing to especially take note of in cygwin is your path. Most troubleshooting with scripts and installed software should begin there.
The other tip I'd give is to use the rxvt terminal over the standard issue cygwin terminal. It might be installed by default nowadays, but check to make sure.
Visual Studio for .net/C++ (even the express editions are useful)
The sysinternals tools rock, especially Procmon and process explorer.
If you do native/C++ work knowing windbg can be helpful
Notepad++ and gvim are my preferred editors
For doing command line/shell stuff I often use python to write short scripts (for anything but the simplest batch file)
If you are familiar with .net then learning powershell isn't much of a stretch and there is a ton of functionality available

Resources