Page 2 of 3

Posted: Wed Jul 25, 2007 10:56 am
by Alboin
JamesM wrote:If you 'became almost fluent in c++ in 2 weeks' that shows a lot of commitment, however I feel inclined to doubt that statement based on the ease at which you give up.
I wouldn't say I'm 100% fluent in anything, and I've been programming for more than 2 weeks. There's always more to learn; especially in C++ where there are numerous techniques beyond the scope of the actual language itself. (Like using templates as a means of functional programming.)
CompDever wrote: I learned all other programming through research, this is too advanced for just research.
No. Nothing is too advanced for research. If it is too advanced, than you haven't researched enough.

Posted: Wed Jul 25, 2007 11:05 am
by JamesM
Yeah, well, that took a while. I originally followed Bran's kernel dev tutorial, and I pulled my linker command from there (this command is literally in the tutorial, right in front of you)

Code: Select all

ld -T link.ld -o kernel.bin start.o main.o scrn.o
Now actually, the -T is optional, so you can ignore that. What you haven't noticed is the 'kernel.bin' after the '-o'. that's the output file. You haven't put one in, in your command (that's by the by, you can do without one, as I'll show). First, lets parse the command you gave LD.

Code: Select all

C:\djgpp\bin\ld.exe link.ld -o main.o ostest.o scrn.o
Program: ld.exe
First parameter: "-o main.o" -- OUTPUT FILE
Second parameter: "ostest.o"
Third parameter: "scrn.o"
So, what your command is actually doing is trying to link ostest.o and scrn.o and save it in a file called main.o. But of course that's failing because none of the symbols in main.o get linked in. The solution is to remove the '-o':

Code: Select all

C:\djgpp\bin\ld.exe link.ld main.o ostest.o scrn.o
That will now compile, and be linked into a flatfile binary called 'a.out'. I compiled it, and show a sample bit of object dumping below.

Code: Select all

james@james-desktop:~/stupid_persons_os$ objdump -d a.out

a.out:     file format elf32-i386

Disassembly of section .text:

00100000 <memcpy>:
  100000:       83 ec 10                sub    $0x10,%esp
  100003:       8b 44 24 18             mov    0x18(%esp),%eax
  100007:       89 44 24 08             mov    %eax,0x8(%esp)
  10000b:       8b 44 24 14             mov    0x14(%esp),%eax
  10000f:       89 44 24 0c             mov    %eax,0xc(%esp)
  100013:       eb 1c                   jmp    100031 <phys+0x31>
  100015:       8b 44 24 08             mov    0x8(%esp),%eax
  100019:       0f b6 10                movzbl (%eax),%edx
  10001c:       8b 44 24 0c             mov    0xc(%esp),%eax
  100020:       88 10                   mov    %dl,(%eax)
  100022:       83 44 24 0c 01          addl   $0x1,0xc(%esp)
(To get it to link I had to remove your underscore from _main -- that's just a compiler difference.).

Now, the thing that pisses me off is how much you complained but the answer was right there in front of you. You hadn't copied bran's command verbatim, you had omitted to put the output file in.
AND, a ld.exe --help or whatever could have TOLD YOU that the argument after -o specifies the target. Do you expect me to sympathise with someone who (a) Doesn't read man pages (which he can get from google) (b) doesn't use the --help command to find out what the arguments are and (c) purports to be 'essentially fluent in c++, don't you wish you could learn as fast as me' and doesn't know the very very basics of a linker? (another way of putting it would be that you don't know your arse from your elbow as far as C is concerned, but that would be too rude.)

JamesM

Posted: Wed Jul 25, 2007 11:45 am
by Brynet-Inc
Nice directory name you're using JamesM 8)

@CompDever, There you go... someone explained it for you.. :wink:

The file will likely be named "a.exe" on your host OS, so don't complain about a missing "a.out" file..

Posted: Wed Jul 25, 2007 3:14 pm
by pcmattman
If you 'became almost fluent in c++ in 2 weeks' that shows a lot of commitment, however I feel inclined to doubt that statement based on the ease at which you give up.
Learnt the language? How many programs have you written from scratch since you learnt? Before I started OS development I'd written at least 50; my 'programming' folder on my hard drive takes up almost 1 GB (90% code).

Posted: Wed Jul 25, 2007 3:46 pm
by Alboin
pcmattman wrote: my 'programming' folder on my hard drive takes up almost 1 GB (90% code).
90% code? 900 megabytes? GCC is ~20 megabytes, the Linux kernel is ~30 megabytes, what are you writing? Even if you had 50 different projects going, you would have ~18 megabytes per project.

I'm guessing the code percentage is a little less than 90%. ;) (Or you're not using version control.)

Posted: Wed Jul 25, 2007 11:25 pm
by pcmattman
Alboin wrote:(Or you're not using version control.)
No version control, and some massive projects. One was a complete replacement for 'explorer.exe' (with 2 rewrites :D).

I guess you could say it'd be more like 60%, with content making up the rest (images, non-code text, etc...).

Either way, I have worked on a lot of projects. One of my all-time favorites was the APICaller library which allowed me to call a function from any DLL with custom arguments. That was fun to write.

Posted: Thu Jul 26, 2007 2:58 am
by sancho1980
the link to the tutorial doesnt work for me: http://www.osdever.net/bkerndev/index.php

is there a working link that i can use??

Posted: Thu Jul 26, 2007 4:26 am
by JamesM
That link normally works. Atm it seems osdever.net's dns has gone arse over tit, so much so that it causes firefox to freeze as soon as I click that link you posted! best bet is to wait a while, I'm sure it'll be back up soon.

Posted: Thu Jul 26, 2007 1:48 pm
by CompDever
Ok, sorry for the delay, i have been very busy for hours and hours.

@JamesM: when i said executable i meant that i could double-click on it and it runs. granted if you have an emulator it may do this (idk).

apparently you are lacking in understanding exactly what i meant by essentially. By learning c++, i have learned how to read, write, and debug it. This does not mean that i know the Standard Library inside and out, considering Standard Libraries vary from compiler to compiler. I have learned those methods which are quintessential to the development of c++, and then i can use google to look up the declaration for a method if i need to (in case i forget something). Or if i haven't a clue how to do something, i take a trip around the web; to places like codeproject.com and others to see what i can find out. Granted, my way of doing something may not be the best way, but usually is effective. (if not, i go back to the 'drawing board' and look up info on that topic). I will not for a second claim to be a better C++ programmer than a lot of people that are c++ programmers. And on a side note i did not become fluent in two weeks, that took me a little longer than learning it.

oh, and even if it looks like it: i do not give up easily, i just take note of when i am not likely to fix a problem. I do not know why there are linker errors even as yet. I have everything defined.

@Alboin:
I learned all other programming through research, this is too advanced for just research.
that means that research is not enough to be successful. It means that i do it, but i still need help

I will be back later to answer the other posts, but gtg for now.

[edit]

@JamesM (again): That is interesting, I must have been really tired when I looked at that linker command. I remember copying and pasting it... perhaps i never clicked the right hotkey and pasted the old linker command from... from... oh, well! i don't rememeber!!! it must have been somewhere else on osdever... Anyways, that would explain it. Considering that that knowing what a linker is and how to operate one on the command line are totally different, i believe i have learned some from this thread. All times previous i was in a Microsoft Visual Studio Environment, never needing to learn the cmd line for it. It is possible that somehow i damaged the cmd line attempt for the linker, though i do not see how. I understand that you would be unhappy about me not copying it accurately, and claiming i had (which i, personally, thought i had). Yes, I knew that -o was the object but apparently my brain couldn't put 2 + 2 together since i thought it was the correct cmd line. And I do understand where you could misconstrue what i said as being snobbish, even when it is not. And I do know more than this forum would show... even though as of now, I can venture to guess that you won't admit it unless next week i come in here with an open source Mac OS X or Vista ready. :D (which would, no doubt, be cool; but is as unlikely as it is impossible)

@Brynet-Inc:
Nice directory name you're using JamesM
:D He thinks very highly of me!! (jk)

and yes i am happy that i understand why my problem existed.

@pcmattman: while we are on the subject of programming, all the non-script (like perl) programming i've done amounts to ~ 120 projects, most of them approximately at the production level of completion. (and by the way learn in past tense is learned not learnt [unless that was an internet slang of the sort that i have not seen :D ]) I am not bragging either, as i have said previously i am not a master of c++, but i know the language (described in high detail above)

@Everyone (mainly JamesM): Thanks for the help I have been given (directed only at JamesM: If you do not like helping people to be able to see the obvious when sometimes they have overlooked it; you might consider a change of forum i am guessing that is the forum for discussing how to do advanced stuff, not the fixing a linker problem. Otherwise stay around and help... I have no doubt that i will need help again in the not-so-far-away future [aka. near future :D ])

Posted: Thu Jul 26, 2007 2:27 pm
by JamesM
@compdever:
when i said executable i meant that i could double-click on it and it runs
When talking with people who supposedly program operating systems I would expect them to understand the definition of executable. As it - it contains code that can be executed
that means that research is not enough to be successful. It means that i do it, but i still need help
Totally untrue. I hardly needed any help when I coded my first OS. And the help I asked for was more about methods and principles than "fix this plz wh1le I m4ke a sandw1ch lolz0r!111"

Before I answer your next point, please realise that i *did* notice the fact that you only added it after an edit. Which means that you didn't read my post where I fixed your problem before you posted. Clever.
That is interesting, I must have been really tired when I looked at that linker command. I remember copying and pasting it...
So, you're too tired to copy/paste properly, so instead of sleeping on it and returning, you post a thread on the forum to get us to sort it out? You posted that linker command in your first post iirc - that means you had ample chance to look at it while I/we were trolling you for wasting our time. What you are saying is that after posting it for us, you didn't even go back to the tutorial you stole it off without even understanding it, to check you hadn't made a typo. Seems like an obvious check to me.

And I didn't say anything about the standard library. There is no standard library when you code your own OS. Therefore it's irrelavent (until you get to linking one in). And they don't vary from compiler to compiler. Just between M$ and Linux (making the assumption that M$ uses its own STL and linux uses glibc/libstdc++, but there are of course other brands of libc available for linux).

Code: Select all

i do not give up easily, i just take note of when i am not likely to fix a problem
I *dare* you to say that again after you have looked at the above comments i made about copy/paste errors.

JamesM

Posted: Thu Jul 26, 2007 3:17 pm
by CompDever
Yes, I accept the dare! Since i had no reason to suspect the linker call as my source of error (since i *thought* i had copied his) it did not really occur to me to check it. Think about it, if you copied the linker call from a respectable tutorial... that would be the last thing to consider to be in question (that is to say before this tutorial...). I know if you respond at all to this you will be saying how wrong my line of logic is. Yes i do know what executable is: but i was talking about it in the sense of something executed by an operating system, not by the computer hardware... Which you can understand, if you choose to.
"fix this plz wh1le I m4ke a sandw1ch lolz0r!111"
So kind of you :D ! Ok, I believe you know i am not like that... (i have not eaten a sandwich in a long time, even though that is beside the point) if you don't who are you to claim intellectual superiority (?) considering how badly you outlook on people who are wise enough to post for help... even when you, Master Superior, thinks it is not a good habit! (lol) And if you hardly needed help on your first OS good job! neither did i! i needed help on my first mixed language operating system. You do not use much logic...
And I didn't say anything about the standard library. There is no standard library when you code your own OS. Therefore it's irrelavent (until you get to linking one in). And they don't vary from compiler to compiler. Just between M$ and Linux (making the assumption that M$ uses its own STL and linux uses glibc/libstdc++, but there are of course other brands of libc available for linux).
This, in other words, says: I was not talking about the Standard Library. There is no standard library when you have to code it! They don't vary from compiler just between compilers like M$ and Linux, and even linux varies also! (as you would put words in my mouth... here these into yours, for your very sad usage of common sense) Basically, I am just trying to prove you wrong, when what I am saying says you are right!!! LOlzOr I h0pe CompDever, doN't notIce mY eRr0r111

Now you know, putting words into other people's mouths just doesn't work, it makes you look dumb when that person points out your mistakes since you were being overly persnickety.

But, even though your help was not presented in the most willing style, it has helped where my *not* so obvious problem was. (there was not a storm of replies blurting out the answer, so it must not have been very obvious)

Posted: Thu Jul 26, 2007 3:21 pm
by pcmattman
when i said executable i meant that i could double-click on it and it runs
Double-click? That's just the operating system's method of allowing you to run a program. Back when the console ruled the world (where are you now?) there was no double-click, you typed the command to run.

An executable is a binary file which contains multiple sections that each contain machine code (pure opcodes).

Code: Select all

By learning c++, i have learned how to read, write, and debug it. This does not mean that i know the Standard Library inside and out, considering Standard Libraries vary from compiler to compiler
How often do you use std::string? std::iterator? std::vector?

None of these are available in an operating system. You build everything from the ground up. Your kernel won't have a library.

And the STL does not vary from compiler to compiler, only the stdlib, and that's an interesting case because Windows (and the Mac?) has a completely different library from *nix systems (whose stdlib is very similar across the board).

We're here to help, but we're not here to spoon-feed newbies to operating system development. Writing an OS is hard, long and difficult. I've spent 7 months on my OS and I'm only just starting to run userland programs. Others here have been working on their OSs for years.

Remember: Google is your friend!

Edit: C++ takes a bit of extra setting up to work with in a kernel (thanks to global objects). I'd suggest starting with C until you understand what's happening.

Posted: Thu Jul 26, 2007 3:24 pm
by CompDever
I know that which you have said.
But, on a side note:
How often do you use std::string? std::iterator? std::vector?
i don't think i have used those. I use other means of accomplishing a goal that is more portable such as char*.

STL = Standard(ST) Library(L)
stdlib = Standard(std) Library(lib)

The difference please?

Posted: Thu Jul 26, 2007 3:29 pm
by pcmattman
STL = Standard Template Library
stdlib = Standard Library

STL is for C++ and makes life easier (std::string is like a char array with += operators and the like).

stdlib is for C, and is just the basic system (printf, file i/o etc...).

You won't use either in your OS, though I suggest you become familiar with them (specifically the stdlib, commonly known as libc).

When you reach the stage where I'm at (usermode programs) the presence of a library that you've ported to your OS makes life that much easier.

Posted: Thu Jul 26, 2007 3:38 pm
by Candy
CompDever wrote:I know that which you have said.
But, on a side note:
How often do you use std::string? std::iterator? std::vector?
i don't think i have used those. I use other means of accomplishing a goal that is more portable such as char*.

STL = Standard(ST) Library(L)
stdlib = Standard(std) Library(lib)

The difference please?
You kind of missed out on that abbreviation. It's the Standard Template Library - hence the T. stdlib.h is C's standard library (used as cstdlib in c++).

The STL gives you things like iostreams, strings, iterators and collections.

C's standard library's stdlib.h gives you basic allocation routines (malloc/free), basic algorithms, basic exiting mechanisms (exit, abort) and so on.

As the title suggests, the STL is (not entirely sure, but I'm pretty sure) solely templates. Even the classes mentioned above are not themselves, but a typedef of a template. The only thing you need to link to are global/static objects used in C++ (such as cout and cerr).

std::string -> std::basic_string<char, std::char_traits<char> >
std::iterator -> Doesn't exist. Is a subtype of the given container and usually typedeffed as an implementation detail class.
std::vector -> is a template itself, usually just implemented. Is explicitly specialized on bools and therefore a vector<bool> isn't a normal vector in lots of aspects, the most important being that you can't take the address of a bool.

And for the most trivial difference, stdlib.h is specified in ISO 9899:1999, cstdlib and the STL are specified in ISO 14882:1998 with a technical corrigendum from 2003. cstdlib is equal (effectively) to stdlib.h but within namespace std.