r/cpp • u/vormestrand • Apr 03 '18
Newer C++ features can create a lot of system yak shaving
https://rachelbythebay.com/w/2018/04/02/cpp/3
u/oldprogrammer Apr 03 '18
Been a while since I did any heavy C++ coding, but I was thinking about the library issues he brings up the other day.
Aren't the linkers smart enough to only pull in the pieces of the library that are used in the binary or does it end up binding the entire library into the binary?
If it is the former then what is the main reason for not going static? Sizes shouldn't get too bad, you eliminate the dynamic loading requirements and don't run the risk of wrong libraries being loaded.
If it is the later then what about an idea of the library being either pre-compiled .o files or just delivered as the source only with defined dependencies, then projects just pull in what they need?
0
Apr 03 '18
[deleted]
1
u/oldprogrammer Apr 03 '18
Imagine that you have X programs that statically link against library Y. If there is a bug in Y you need to recompile and distribute and install X programs. If they are dynamically linked you can simply replace Y.
While a true scenario, if a new version of Y is deployed that has a bug or a compatibility issue then you've broken all X applications as well.
The problem is that c++ doesn't have an single dependency management/ build tool
This is I think the biggest issue, but what would such a dependency management/build tool look like for C++ since the end result is native binaries? Would it fetch say some form of pre-compiled or source code and build it on the fly for the target platform?
Or do we just need a Maven type repository with pre-compiled binaries for each platform and use a classifier like we do in Java for native jars as for example the lwjgl (opengl for java) does to fetch the platform shared libs?
2
u/sumo952 Apr 03 '18
There was this thing linked a week or so ago here which makes newer compilers available on RHEL I think.
6
1
u/r2vcap Apr 03 '18
is there are any problems with -Wl,-rpath=$ORIGIN/../lib ? No, I don't think so. Just shipping libstdc++ and libgcc_s if you need to use newer C++ compiler and can't use RHEL's devtoolset.
2
Apr 03 '18
It's good for application deployment. It's not enough if you're writing a library and end user will load his preferred libstd first.
19
u/[deleted] Apr 03 '18 edited Apr 03 '18
What does a forward declaration have to do with a scoped_ptr? Am I reading it wrong?
This whole article is less about C++ and more about a particular version of a linux distro that packaged a specific version of a C++ compiler years ago. I'm not sure what the takeaway from this article is supposed to be.
edit: grammar