For Unix/Linux C programmers, a quick guide to Windows programming?

If you're developing on Windows, I'd recommend Visual Studio, forget all that GNU stuff here.

Want common makefiles? CMake.
What specific issue are you having? What kind of guide? You can do basically everything you want with mingw-gcc. (There are some fringes of the Win32 API that it doesn't have implemented, iirc, but it's pretty good.)

You can use vim, make, and ports of other tools (e.g. grep).
Last edited on
For a compiler GCC and clang(LLVM) are your options.
There is even a Vim for Windows: https://www.vim.org/download.php
GCC comes with make, not sure about clang
cygwin does produce native executable files. It links them to that awful dll, but it is a windows compiler and the programs it makes will work on any windows machine if you also distribute any libraries it depends on. The unix shell in cygwin is 'fake' -- the programs like grep and such are native windows exe files that work in cmd just fine, without the fake shell. The programs built by its compilers also work from cmd, without the shell. The shell isn't a VM for a unix OS, its a simulator running windows code on windows.

As far as windows gui coding, you have 3 major options (with tons of minors in the mix too).
- you can use MFC, microsoft's 'original' GUI library. Its weird, partly due to age, and partly due to the good drugs available in the early 80s. It hasn't been upgraded to 64 bit, but that does not matter all that much for simple programs -- the working code can use 64 bit and modern c++, only the gui is limited to what we had in windows 98 or whatever. It is still supported, and not exactly obsolete. Be prepared to deal with tons of typedefs/macros/etc, eg BOOL instead of bool, because bool did not exist in c++ at that time, etc.

- you can use managed c++, which looks like a 3 year old was allowed to edit the source code but the only button that worked on his keyboard was the ^ character. Its even weirder than MFC, but in a new and exciting ways. It is supposed to be the modern replacement for MFC, but .. well... you can look at it and see if you want to go there.

- you can use a third party GUI library. This is full of advantages: you don't have to deal with the above, and a lot of these are portable so the same UI works on unix and windows and even macs. A popular one is QT (cute). There are several others.

- a minor but popular option, and usually preferred to managed c++ is to throw in the towel and just code the UI in c# (its a nice little language, but M$ pushes it too hard rather than just let it sell itself) and call out to the C++ objects for the real work. Its not too hard to set this up.

for any of the above, I like visual studio. However, I also use notepad ++ with g++ (cygwin!) for a lot of smaller programs (like examples in this forum, too small to make a project and deal with visual).
Last edited on
Since the advent of 32 bit Windows in the mid 1990s I've mostly used Microsoft's Windows Api directly to build Windows applications. Built on top of that are a lot of different programming languages and application development frameworks, but for me direct use of the Api has worked best. It's the lowest level interface to the operating system.

Not that I haven't tried a lot of alternatives. In the late 90s I especially liked pre-.NET Visual Basic. With that one could use drag and drop Visual Programming techniques to build applications. That is currently available in the flavor of C# and C++/CLI. MFC was another abomination I tried. I guess I wasn't taking strong enough drugs to make its use painless.

Common to all these wrapper systems is the necessity of packaging large runtime dependencies with the application. I guess to most that isn't an issue, but to me it was.

If you are actually partial to using C instead of C++ and want to do non-GUI apps/utilities, The Windows Api Console Subsystem would come natural to you I think. It's pretty easy to use mingw of MSVC build chains for console or GUI apps.
M'ok, you want to create Windows based apps. I'd recommend getting Visual Studio 2022 (or 2019 if your Win PC is 32-bit).

I suggest Visual Studio for a couple of reasons:

1. It is an editor, compiler and debugger in one package. The debugger is one of the best available for Windows.

2. Via the IDE it is possible to batch build for 32- and 64-bit apps.

3. Command-line compiling is still available if you want it.

Walkthrough: Using MSBuild to Create a Visual C++ Project - https://docs.microsoft.com/en-us/cpp/build/walkthrough-using-msbuild-to-create-a-visual-cpp-project?view=msvc-170

One thing to note if you do decide to use VS C/C++ support is not automatically installed. You have to manually select it either on install or modify a previous install.

Install C and C++ support in Visual Studio - https://docs.microsoft.com/en-us/cpp/build/vscpp-step-0-installation?view=msvc-170

There are two "versions" of Visual Studio available. Visual Studio & Visual Studio Code. DO NOT get the VS Code version.

https://visualstudio.microsoft.com/vs/

There should be very little to change with your source(s) if you wrote the code to adhere to the ISO standard(s) for C/C++. Especially if you are creating console mode apps. If you wrote code that used system level tweaks, or does GUI, then you'd have to learn the Windows variants.

A Microsoft tutorial or two using Visual Studio for a console app might be in order:

1. Overview of Windows Programming in C++ - Overview of Windows Programming in C++

2. Walkthrough: Creating a Standard C++ Program (C++) - https://docs.microsoft.com/en-us/cpp/windows/walkthrough-creating-a-standard-cpp-program-cpp?view=msvc-170

Something else you might want to read about are libraries, static and dynamic:

Walkthrough: Create and use a static library - https://docs.microsoft.com/en-us/cpp/build/walkthrough-creating-and-using-a-static-library-cpp?view=msvc-170

Walkthrough: Create and use your own Dynamic Link Library (C++) - https://docs.microsoft.com/en-us/cpp/build/walkthrough-creating-and-using-a-dynamic-link-library-cpp?view=msvc-170

Creating GUI apps is a bit more complicated vs. a console mode app. There is a somewhat out-dated non-MS tutorial that show the basics of the WinAPI (non-MFC):

theForger's Win32 API Programming Tutorial - http://www.winprog.org/tutorial/
Learn C++ has an online introductory tutorial for working with the Visual Studio IDE, Chapter 0:

https://www.learncpp.com/cpp-tutorial/installing-an-integrated-development-environment-ide/

If'n you are not familiar with C++ the entire Learn C++ website is a good resource, though it doesn't delve into all of what the C++ standard has to offer.

A decent online reference resource for C and C++ is (not for learning!):

https://en.cppreference.com/w/
Topic archived. No new replies allowed.