"Why is it that package managers are unnecessarily hard?" — or are the...
source link: https://nibblestew.blogspot.com/2022/09/why-is-it-that-package-managers-are.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
A gathering of development thoughts of Jussi Pakkanen. Some of you may know him as the creator of the Meson build system.
Wednesday, September 28, 2022
"Why is it that package managers are unnecessarily hard?" — or are they?
At the moment the top rated post in In the C++ subreddit is Why is it that package managers are unnecessarily hard?. The poster wants to create an application that uses fmt and SDL2. After writing a lengthy and complicated (for the task) build file, installing a package manager, integrating the two and then trying to build their code the end result fails leaving only incomprehensible error messages in its wake.
The poster is understandably frustrated about all this and asks a reasonable question about the state of package management. The obvious follow-up question, then, would be whether they need to be hard. Let's try to answer that by implementing the thing they were trying to do from absolute scratch using Meson. For extra challenge we'll do it on Windows to be entirely sure we are not using any external dependency providers.
Prerequisites
- A fresh Windows install with Visual Studio
- No vcpkg, Conan or any other third party package manager installed (more strictly, they can be installed, just ensure that they are not used)
- Meson installed so that you can run it just by typing meson from a VS dev tools command prompt (if you set it up so that you run python meson.py or meson.py, adjust the commands below accordingly)
- Ninja installed in the same way (you can also use the VS solution generator if you prefer in which case this is not needed)
The steps required
Create a subdirectory to hold source files.
Create a meson.build file in said dir with the following contents.
project('deptest', 'cpp',default_options: ['default_library=static',
'cpp_std=c++latest'])
fmt_dep = dependency('fmt')
sdl2_dep = dependency('sdl2')
executable('deptest', 'deptest.cpp',
dependencies: [sdl2_dep, fmt_dep])
Create a deptest.cpp file in the same dir with the following contents:
#include<SDL.h>
if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) != 0) {
fmt::print("Unable to initialize SDL: {}", SDL_GetError());
return 1;
}
SDL_version sdlver;
SDL_GetVersion(&sdlver);
fmt::print("Currently using SDL version {}.{}.{}.",
sdlver.major, sdlver.minor, sdlver.patch);
return 0;
}
Start a Visual Studio x64 dev tools command prompt, cd into the source directory and run the following commands.
meson wrap install fmt
meson wrap install sdl2
meson build
ninja -C build
This is all you need to do to get the following output:
Currently using SDL version 2.24.0.
Most people would probably agree that this is not "unnecessarily hard". Some might even call it easy.
No comments:
Post a Comment
Recommend
-
7
Why apk-tools is different than other package managers Alpine as you may know uses the apk-tools package manager, which we built because pre-existing package manag...
-
2
4 NPM Alternatives: Best JS Package Managers and Publishing ToolsFor years every JS developer worked daily with packages installed using NPM client, often from the NPM registry or an organization’s private regist...
-
7
Managing people Returning to the Office Will Be Hard. Here’s How Managers Can Make It Easier. ...
-
2
Corepack is the new built-in tool for preparing the required package manager for our projects. Let's see what comes with this new package for packagers. 📦 Installation The new Node.js LTS v16 will be released at the e...
-
7
Thoughts on macOS Package Managers Friday, April 26, 2019 A couple of months ago, I uninstalled Homebrew and migrated my configuration to Mac...
-
3
Let's talk about the security nightmare of handling hundreds of different game installations. Over the years I have become the de facto security engineer responsible for EA's "game package managers"
-
3
Let's talk about the security nightmare of handling hundreds of different game installations. Over the years I have become the de facto security engineer responsible for EA's "game package managers"
-
2
Copy link Contributor
-
5
Peop...
-
4
JavaScript Weekly Issue 680 « Prev ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK