Thanks for all that, if that was intended as somehow to answer and solve why these examples don't work, well then i give up on c++ because its just too complicated to learn. Not the code, but how to even get a simple example to run. I mean no disrespect at all, but I don't understand a single thing in your post.
Unfortunately, this is one of the most archaic things about C++. C++ inherited its toolchain model from C, which was designed in the early 70s under the constraints of the computers at the time - memory probably in the low kilobytes and perhaps not more than a few megabytes of disk storage.
While the language has evolved over time, the tools to build and link function conceptually almost the same as they did back then.
This is a common stumbling block, but you can make your way through it if you persevere.