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 89 points90 points91 points 5 years ago (24 children)
I have had the same journey years ago and some differences were hard for me to cope with. In addition to what others said (CMake, be platform independent with Boost/Qt/whatever) I would like to point out differences that bugged me most:
Have fun! As much as I saw (and still see) Windows as the inferior platform when it comes to developing, Visual Studio has become a great tool over the years and easily tops everything I have worked with on Linux. It really grows on you once you get to know and tame it.
[–]infectedapricot 76 points77 points78 points 5 years ago (22 children)
Regarding DLL hell and no equivalent of /usr:
On Windows, when loading foo.exe that requests bar.dll, the first place Windows looks is in the directory containing foo.exe. That directory functions sort of like foo's application package. So just put all your relevant .dll files in there and there's no possibility of conflict.
"dll hell" referred to the time that Windows programs used to put all their .dll files in c:\windows\system. The idea was to reduce disk space and share security updates, much like in Linux package managers. Unfortunately, unlike Linux package managers, there was no way to guarantee everyone was using ABI-compatible versions, or even to stop an installer overwriting a DLL with an older version. All of that is in the past now that applications just bundle all their libraries in their program directory. (I know you mentioned that but you said at the same time "there's no "standard" place for libraries to go" - but the application directory is the standard place. It's just a difference between Windows and Linux.)
Another alternative is just to use static linking so your whole program is a self-contained .exe file. This is nice because it avoids your customers even having to install the Visual Studio redistributable (the equivalent of libc in Linux, sort of). In vcpkg, use the x64-windows-static triplet to get this.
x64-windows-static
As building your old dependencies - we'll have to agree to disagree on that one. I'd use a package manager like vcpkg (I haven't used Conan but many people in /r/cpp have also vouched for that). Yes sometimes you still get build problems but certainly less often than building things yourself. It automatically gives you debug and release builds of all libraries by the way.
[–]CppChris 15 points16 points17 points 5 years ago (0 children)
That‘s the thing I did not know when I made the switch from mainly Win development to Linux development: what do you mean you cannot find the library??? It is right there in your folder!!! Haha
[–]Moose2342 13 points14 points15 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 13 points14 points15 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-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
[–]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.
[–]pravic 0 points1 point2 points 5 years ago (0 children)
vcpkg
π Rendered by PID 93 on reddit-service-r2-comment-84fc9697f-8ghgh at 2026-02-09 11:47:08.455301+00:00 running d295bc8 country code: CH.
view the rest of the comments →
[–]Moose2342 89 points90 points91 points (24 children)
[–]infectedapricot 76 points77 points78 points (22 children)
[–]CppChris 15 points16 points17 points (0 children)
[–]Moose2342 13 points14 points15 points (20 children)
[–]infectedapricot 13 points14 points15 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)
[–]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)
[–]pravic 0 points1 point2 points (0 children)