water cooler :: C++ without libraries
I've searched through man pages and google, without success, so perhaps someone could enlighten me...
To begin with, I'm one of those people that just has to know how things work. If you start to think to yourself, "So what?" please bear with me.
Okay, almost all programs start with something to the effect of "include these libraries". In c++, these libraries give the user many powerful functions, as well as more simple things like outputting text to a console.
Now, here's my question. If you take away all of those libraries and functions, what are you left with? What functions and operators are available?
I'm trying to make a tiny program that, when you turn on your computer, prints "hello world", on the screen. I want to take an unused computer, dump this into the boot sector, and see it run.
This is being done for a few reasons. First off, it would really give me a chance to learn about the boot process. Second, because I would get to learn about programming without libraries (I have no illusions about the difficulty, but with enough persistence, reference books, and caffeine, I'm sure I can do it!). Third, it might pave the way for bigger and better things. Finally, because I can!
Thanks in advance!
I don't know much about programming, but I'm guessing that you really can't do anything without at least one or two includes.
Even a simple "hello world" needs iostream, which may need more includes itself. C++ is an object-oriented programming language, which by definition uses various external files to do its work.
The short answer is sure you can do that. No libraries needed. You need to understand what the boot sector wants to see and then put your program where it needs to go. You will need to put your text string into memory and make a BIOS call to write the text to the screen, and then probably set up an infinite loop after that to keep anything else from executing.
You need to look up boot sector layout and BIOS calls, and looking into the linux boot process might help too.
original here.