This is not really true. Only the GPL license and a few related licenses are "copyleft", forcing you to opensource the software constructed based on the GPL software. However, you can freely use for example the LGPL libraries. In fact, the LGPL was created specifically with this goal in mind -- creating closed source applications with shared open source LGPL libraries. Moreover, under BSD or BSD-like license (for example, Python) allows you to essentially take as it is and do whatever you like with it.
In other words, open source does not enforce open source. Moreover, opensource does not mean "free as in beer". You are perfectly allowed to charge for open source programs, or create an open source program but ask for money when selling data (like media files or resources associated with that program).
To sum it up:
- BSD-like licenses allow you to freely modify and distribute the code as you see fit;
- LGPL (lesser GNU public license) allows the creation of proprietary code linked to shared libraries which are open source. For example, the entire glibc is LGPL;
- GPL license forces you to distribute any modifications to a GPL-program under GPL.
Thus, you can happily write your program, linking it to a broad range of libraries or even directly incorporating pieces of alien code, compile it and sell it as a proprietary, closed source program, as long as you do not distribute modified GPL'ed programs.