4 ms·
A common mistake I see is to let the tools/frameworks make the decisions. The engineer should make the decisions. If the tools don't let the engineer do what he
by plq 5y ago
A common mistake I see is to let the tools/frameworks make the decisions. The engineer should make the decisions. If the tools don't let the engineer do what he wants, he must change the tools.
Not sure how much experience you have with native development but, as a person who has production code running on windows, macos and linux, frankly I don't see much difference. Getting together almost all of the moving parts that make a modern OS tick behind simple API calls is no simple feat. Native development is complex because ... well it's a complex problem. Microsoft platforms have always been clunky so if you add that as well, it might seem unsurmountable if you don't know what you're looking for.
Linux is the most developer-friendly OS out there. What's nice, its GUI toolkits have the advantage of being cross-platform so if you learn how to use them, you can easily port your code to other platforms. For windows development I'd go with Qt or Gtk instead of full-on native nowadays. Qt takes you %95 of the way (Gtk a bit less) and for what's left you can drop to native code which wouldn't be too difficult.
However, for the sake of argument, let's try using the native apis.
Here's the checklist: Get a compiler, get an editor, write some code, generate build files, build, run, iterate.
1. Get a compiler. For windows, MSVC is the obvious choice. My MSVC provisioning script is 40 lines of powershell plus some json file I exported after doing the first manual install.
2. Get an editor. Notepad++ will let your feet get wet but for advanced stuff like completion and refactoring, get a real IDE like Qt Creator, Visual Studio or CLion. But for now, notepad++ it is.
3. Ok, time to write some code. I DuckDuck "windows gui hello world" and clicking around the first result lands me here: https://docs.microsoft.com/en-us/windows/win32/learnwin32/your-first-windows-program https://docs.microsoft.com/en-us/windows/win32/learnwin32/yo... so we have our hello world sample. Get the code from there and save it as main.cpp
4. Now let's compile the code. Running cl.exe by hand is doable but won't take you very far. We need a build configuration system. It looks like CMake and ninja is now bundled with Visual Studio so let's use them. I DuckDuck "cmake windows hello world" but don't get much and you turn to Google and you get these three lines:
cmake_minimum_required(VERSION 2.4)
project(hello_world)
add_executable(app WIN32 main.cpp)
Good! now, launch a developer shell and do this:
cd \path\to\my\code
mkdir build
cd build
cmake ..
And when I type make ... wait what is this? What is a .sln file?? Visual Studio Solution?? Sorry cmake, that's not what I want, give me a proper Makefile. Or build.ninja.
Let's try again:
cd ..
rm -r build
mkdir build
cd build
cmake .. -G Ninja
ninja
.\app.exe
Ah! That's more like it. And you take it from there.
Never let your tools dictate your actions. You're the engineer. The tools should do your bidding. As for the framework, just use Qt. If not, I think the latest fad is WinUI but Win32/MFC is here forever.
I actually put all this here along with my MSVC Provisioning script: https://github.com/plq/hello-win32 https://github.com/plq/hello-win32
Hope it helps!