occamin
The other side of the coin, is if everyone rewrote everything from scratch, there would also be a tremendous amount of wasted effort and time cost.
What about all the wasted time and effort that goes into dealing with bad libraries? I think far too much faith is put in the amount of time & effort libraries "save" us.
e.g. I once worked on a synth plug-in where I was asked to write some DSP filters. After pulling it from the repo, it took me 3 days to be able to just
build the thing because there were so many libraries (most of which used several CMake scripts). Needless to say, I refuse to work with this person ever again. :)
Then there are bad APIs, compatibility issues, bugs you have no control over, etc. etc. that all contribute to additional wasted time and frustration in dealing with libraries. Granted, there are some good ones like SDL and the STB libraries, but I've been burned far more than the alternative.
But also like you said, in practice when budgets and scope come into the picture, it's unavoidable at times. Fortunately where I work, I have a high degree of autonomy so I can often make decisions against using libraries whenever possible, but on one project in particular it was impossible not to use a library (with an especially bad API at that!). I find it demoralizing, and it saps my productivity because it's so frustrating to work with.
All my other projects at work are more interesting and rewarding though, but it's telling that even just one project with a horrible library can drag down my day! :(