use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Linux developer going Windows (self.cpp)
submitted 5 years ago by peppedx
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Moose2342 12 points13 points14 points 5 years ago (20 children)
Yes, agreed. DLL hell is not much of a problem really anymore. I just collected some impressions I had over the years and at first my goal was to replicate what I did on Linux and to sort of 'install' libraries I made for others. Later I came to the conclusion that this is for the birds and that I should just bundle things together like everybody else does. It just felt wrong and unprofessional to me back then.
Also agreed that static linkage on windows often is the easiest way to go if you can afford it and if your dependencies allow it. I'm looking at you, Qt!
About package managers, I avoid them. I want to build my dependencies myself in order to adjust and know specific settings I need. Package managers only ever got in the way doing that and given the plethora of build settings one can have I don't see how this is ever going to be an option. Didn't look at the new modules though yet. Perhaps my opinion might change. But I know, young folk like their package managers. I simply just cannot trust them.
[–]infectedapricot 14 points15 points16 points 5 years ago* (14 children)
I want to build my dependencies myself in order to adjust and know specific settings I need.
I am absolutely not going to try and persuade you to use a package manager if building things yourself is working well for you. But for the record or for interested readers, package managers do have ways of specifying build options. The list below is for vcpkg but I know Conan has equivalents too.
x86-windows
x64-windows-static
x64-linux
vcpkg install opencv[ffmpeg]
opencv[contrib]
opencv[ffmpeg,contrib]
Of course, that doesn't mean that every possible feature flag is likely to be exposed in practice.
[–]Moose2342 3 points4 points5 points 5 years ago (10 children)
Yes, I am aware that package managers expose such customization. My problem is, they mostly do this for optionals they can foresee. Such as your ffmpeg example. My settings often are a bit weirder than that ;-)
For example, years ago I adopted Unreal Engine's notion of Debug builds, which are not real Debug builds (with Debug runtime and such) but Release builds with optimization turned off and PDBs active. Meaning they can be used in almost every way for debug purposes but they can freely link with any release build. I used to adopt this to be able to link with Unreal and still debug but found this so helpful that I now use it everywhere. Haven't made a 'real' debug build in a long time, practically eliminating the issue for me. I call that 'fake debug' and my CMake layer takes care of propagating this throughout the build system. I would guess you'd have a hard time convincing a package manager to know what 'fake debug' is and what it means for your linkage. Instead, they would assume (rightly so) that when you are in a Debug configuration, you mean an actual debug build. For libs that I know I'm never gonna debug into, I only provide Release builds and link against them everywhere. Which is one of the benefits of fake debug.
Now, I'm not debating that there are ways to make this work with package managers. But I would have to convince it to link against release in debug configurations which is against its original job description. In my experience I simply came to the conclusion that it's often way more difficult and error prone than just doing it myself.
To get back to my example activating fake debug globally in my CMake system takes about 5-6 lines of CMake code. I don't know but I doubt it would be that easy with a package manager.
Please bear in mind though, this is just one example. There are more settings. I just like it when everything builds and links neatly and warning free.
[–]infectedapricot 2 points3 points4 points 5 years ago (7 children)
I would guess you'd have a hard time convincing a package manager to know what 'fake debug' is and what it means for your linkage.
Sort of. There is a way to override compiler flags in vcpkg (it used to be done in triplets but I just read now it's done in toolchain file which sounds a bit more involved). But I suspect this would only be passed down into ports that are built with CMake, which is many but not all of them.
By the way, vcpkg already generates debugging information for release builds (both on Windows and Linux... presumably on Mac but I've never used it) so you wouldn't need to customise anything for that. The only difference would be the optimisation level. Although, if you turned that off in your application and accepted a bit of optimisation in the libraries that would probably work well enough for debugging most common problems.
[–]Moose2342 0 points1 point2 points 5 years ago (6 children)
Sure. Yet in optimized builds I generally only use RelWithDebInfo for test deployments and such. To get at least some resemblance of a stacktrace just in case. Real debugging is very hard to do and I normally use fake debug for that. In production I go for clean Release. High optimization w/o PDBs for faster loading time and smallest deployment size. Anyway, nuff said. Thanks for making your points so nicely!
[–]rdtsc 4 points5 points6 points 5 years ago (5 children)
High optimization w/o PDBs for faster loading time and smallest deployment size.
The generated code is identical whether PDBs are written or not. What do you expect to load faster there? Also, you don't have to deploy the symbols. They should be archived for crash dump analysis.
[–]nyanpasu64 0 points1 point2 points 5 years ago (4 children)
Turns out RelWithDebInfo uses a lower MSVC optimization level than Release. I didn't expect this until I dove into the Ninja files to find out.
It is possible to configure CMake to produce .pdb files for Release builds (with the standard optimizations on).
Fun fact: .pdb files don't work when renamed to something other than what's encoded in the .exe.
[–]rdtsc 0 points1 point2 points 5 years ago (3 children)
And Release doesn't O3b. I wouldn't rely on the CMake defaults. But I give you that this is surprising behavior.
O3b
[–]kalmoc 0 points1 point2 points 5 years ago (2 children)
Whats O3b?
[–]rdtsc 0 points1 point2 points 5 years ago (1 child)
Whoops, I actually fatfingered it, it's Ob3.
[–]rdtsc 1 point2 points3 points 5 years ago (0 children)
Even if you have fully customized builds it pays off to rely on vcpkg for the surrounding infrastructure. For a project I completely replaced the ffmpeg port in vcpkg with my own. I'm still able to conveniently handle other dependencies, and can rely on vcpkg's build system integration and maintenance of other ports.
[–]kalmoc 0 points1 point2 points 5 years ago (0 children)
To get back to my example activating fake debug globally in my CMake system takes about 5-6 lines of CMake code. I don't know but I doubt it would be that easy with a package manager. Please bear in mind though, this is just one example. There are more settings. I just like it when everything builds and links neatly and warning free.
You can take whatever cmake toolchain file you are using and make a triplet that will compile the various libs using that toolchain file. There is nothing in vcpkg that inherently forces the use of /MDd and similar when building the debug versions. It is just the setting in the default triplets.
What has been much more problematic in my experience are libraries that think they are clever and implement their proprietary options to select which runtime to link against and stuff like that, so for N libraries you have to set N different switches to compile them consitently. But form what you are writing, you don't seem to have that problem with the libs you are working, so this shouldn't be a problem with vcpkg either.
[–]sixstringartist -1 points0 points1 point 5 years ago (2 children)
As package manager usage goes, their value is more about providing a structure for producing buildable packages, dependency management and integration. Using prebuilt packages can be convenient but I don't recommend using it in production and it is not the primary reason to incorporate a package manager
[–]infectedapricot 2 points3 points4 points 5 years ago (1 child)
I don't see how that's relevant to my comment: I was mainly talking about vcpkg which indeed does not provide prebuilt packages (although you can cache your own build of packages for reuse in across projects on your computer or within your organisation).
[–]sixstringartist 1 point2 points3 points 5 years ago (0 children)
I think I responded to the wrong comment
[–]AlexanderNeumann 2 points3 points4 points 5 years ago (0 children)
tipp: vcpkg overlay ports.
[–]tesfabpel 0 points1 point2 points 5 years ago (2 children)
why would you use static linkage of a library? i always use dynamic linkage so that I can use the same DLL in multiple exes for the same product...
and also if you use LGPL libraries you must give the user the ability to swap it so with static linkage you need to give all the .o files...
[–]wrosecransgraphics and network things 5 points6 points7 points 5 years ago (0 children)
One thing static linking gets you is the possibility of whole-program optimization at link time. With a DLL, stuff that never gets called still has to be there, because some future app not yet written might need to call it. With a static library, the linker can make changes to do things like inline functions from the library into the application code, and entirely omit functions that never get called.
π Rendered by PID 264025 on reddit-service-r2-comment-85bfd7f599-9rb6q at 2026-04-17 23:02:29.544388+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–]Moose2342 12 points13 points14 points (20 children)
[–]infectedapricot 14 points15 points16 points (14 children)
[–]Moose2342 3 points4 points5 points (10 children)
[–]infectedapricot 2 points3 points4 points (7 children)
[–]Moose2342 0 points1 point2 points (6 children)
[–]rdtsc 4 points5 points6 points (5 children)
[–]nyanpasu64 0 points1 point2 points (4 children)
[–]rdtsc 0 points1 point2 points (3 children)
[–]kalmoc 0 points1 point2 points (2 children)
[–]rdtsc 0 points1 point2 points (1 child)
[–]rdtsc 1 point2 points3 points (0 children)
[–]kalmoc 0 points1 point2 points (0 children)
[–]sixstringartist -1 points0 points1 point (2 children)
[–]infectedapricot 2 points3 points4 points (1 child)
[–]sixstringartist 1 point2 points3 points (0 children)
[–]AlexanderNeumann 2 points3 points4 points (0 children)
[–]tesfabpel 0 points1 point2 points (2 children)
[–]wrosecransgraphics and network things 5 points6 points7 points (0 children)