Page 1 of 1

[SOLVED]Errors in tutorial?

Posted: Sun Aug 24, 2014 5:36 pm
by bashcommando
I completely followed the tutorial on writing a OS with D and assembly like I always do when following a tutorial for the first time. When linking the files start.o and kernel.main.d together using linker.ld just like the tutorial said it gave me the following error.

Code: Select all

kernel.main.o: In function `main':
/home/bashcommando/Desktop/starfruit/beta/kernel.main.d:10: undefined reference to `_d_criticalenter'
/home/bashcommando/Desktop/starfruit/beta/kernel.main.d:10: undefined reference to `_d_criticalexit'
/home/bashcommando/Desktop/starfruit/beta/kernel.main.d:12: undefined reference to `_d_criticalenter'
/home/bashcommando/Desktop/starfruit/beta/kernel.main.d:12: undefined reference to `_d_criticalexit'
/home/bashcommando/Desktop/starfruit/beta/kernel.main.d:13: undefined reference to `_d_criticalenter'
/home/bashcommando/Desktop/starfruit/beta/kernel.main.d:13: undefined reference to `_d_criticalexit'
kernel.main.o: In function `kernel.main._D6kernel4main9__modinitFZv':
/home/bashcommando/Desktop/starfruit/beta/kernel.main.d:14: undefined reference to `_Dmodule_ref'
/home/bashcommando/Desktop/starfruit/beta/kernel.main.d:14: undefined reference to `_Dmodule_ref'

Re: Errors in tutorial?

Posted: Sun Aug 24, 2014 6:02 pm
by Bender
I think there was a option to enable leading underscores (fleading-underscores maybe), enable that and then compile or do it the better way, fix your symbols.
EDIT: The above might not be the issue. I think the compiler expects d_criticalenter and d_criticalexit to be predefined.

Re: Errors in tutorial?

Posted: Mon Aug 25, 2014 9:27 am
by bashcommando
Bender wrote:I think there was a option to enable leading underscores (fleading-underscores maybe), enable that and then compile or do it the better way, fix your symbols.
EDIT: The above might not be the issue. I think the compiler expects d_criticalenter and d_criticalexit to be predefined.
I typed exactly what the tutorial said. That also means that there is a error in the tutorial. I just figured I should point it out.

Re: Errors in tutorial?

Posted: Mon Aug 25, 2014 11:06 am
by klange
volatile was removed from the D compiler and silently replaced with calls to the D runtime's criticalenter / criticalexit routines. Had you asked Google, you would have found this email thread. There is no error in the tutorial except that it was written before this change to D and has not been updated since.

Re: Errors in tutorial?

Posted: Mon Aug 25, 2014 1:12 pm
by neon
Hello,
I typed exactly what the tutorial said. That also means that there is a error in the tutorial
Not necessarily. Minor differences between build environments and host operating system can result in errors independent of the tutorial or what the tutorial expects. In addition, the resulting code can be very different resulting in crashes or compiler assuming something that should not yet be used. This is specifically true in operating system development. Rule of thumb is to never copy and paste as there is no guarantee it will work and know your tool chain very well in order to resolve minor details such as the one you are facing now.

Re: Errors in tutorial?

Posted: Mon Aug 25, 2014 5:09 pm
by bashcommando
neon wrote:Hello,
I typed exactly what the tutorial said. That also means that there is a error in the tutorial
Not necessarily. Minor differences between build environments and host operating system can result in errors independent of the tutorial or what the tutorial expects. In addition, the resulting code can be very different resulting in crashes or compiler assuming something that should not yet be used. This is specifically true in operating system development. Rule of thumb is to never copy and paste as there is no guarantee it will work and know your tool chain very well in order to resolve minor details such as the one you are facing now.
Then again, the e-mail thread. Somebody should update it.

Re: Errors in tutorial?

Posted: Mon Aug 25, 2014 7:38 pm
by neon
bashcommando wrote:
neon wrote:Hello,
I typed exactly what the tutorial said. That also means that there is a error in the tutorial
Not necessarily. Minor differences between build environments and host operating system can result in errors independent of the tutorial or what the tutorial expects. In addition, the resulting code can be very different resulting in crashes or compiler assuming something that should not yet be used. This is specifically true in operating system development. Rule of thumb is to never copy and paste as there is no guarantee it will work and know your tool chain very well in order to resolve minor details such as the one you are facing now.
Then again, the e-mail thread. Somebody should update it.
It is not possible to accommodate the above. I do not quite think you understand the level of detail involved here; it is important to realize that errors will always occur due the above which is why copying and pasting system code will not work well unless you are also copying the build environment and design structure. It is clear that your build environment is different then what was assumed.

It is also very common to have custom build environments and tool chains cross compiled or targeting a specific operating system. The smallest difference can yield to errors. This does not mean the code nor build environment is wrong - rather just differences in design and architecture make different assumptions and have different requirements.

Again, the rule of thumb : Never copy and paste system code and never assume any tutorial or code you find online that provides system code will work for you without modification unless you have a compatible build environment and design suitable to meet the requirements and assumptions of that code - on the design, architecture, and depending on the code, binary level.

Re: Errors in tutorial?

Posted: Tue Aug 26, 2014 12:15 am
by iansjack
bashcommando wrote:
neon wrote:Hello,
I typed exactly what the tutorial said. That also means that there is a error in the tutorial
Not necessarily. Minor differences between build environments and host operating system can result in errors independent of the tutorial or what the tutorial expects. In addition, the resulting code can be very different resulting in crashes or compiler assuming something that should not yet be used. This is specifically true in operating system development. Rule of thumb is to never copy and paste as there is no guarantee it will work and know your tool chain very well in order to resolve minor details such as the one you are facing now.
Then again, the e-mail thread. Somebody should update it.
So go ahead - update it. You are somebody.

They say that you learn more when things go wrong then when they go right. This is true of life in general and very true of OS development. You need to understand your computer hardware and your toolchain intimately. So now you have learnt more than you would have if copy and pasting had just worked.

This is a wiki. Anyone can update it. If you think there are useful changes to be made to it then share your new-found knowledge by updating it. Personally, I'm not convinced that bare-bones tutorials do more good than harm.

Re: Errors in tutorial?

Posted: Tue Aug 26, 2014 8:47 am
by no92
iansjack wrote:This is a wiki. Anyone can update it. If you think there are useful changes to be made to it then share your new-found knowledge by updating it. Personally, I'm not convinced that bare-bones tutorials do more good than harm.
If we hadn't the BareBones/Bran's/jmolloy's tutorials, most beginners would just copy from other operating systems, which isn't good, too.

I think it's good that these tutorials exist, but they're sometimes very far away from being perfect. I don't love tutorials that state that assembly language isn't required, simply because that's not true. If you don't have an idea about how, for example, memory addressing works, you will run into problems sooner or later. Also, we should do more in order to prevent new OSdevers from copy&pasting code (I know, some people say it doesn't help, but I still believe in humanity), e.g. by not showing all the code. If we let them do some very basic methods by themselves (let's say the C memset), we could be better off.

Again, keep in mind that's only my personal opinion.

Re: Errors in tutorial?

Posted: Tue Aug 26, 2014 9:55 am
by iansjack
I'm still not convinced.

I don't think that the people who copy and paste from bare-bones tutorials would be doing the same from, for example, the Linux source code. Mind they'd learn a lot more (before and after) if they did. I'd rather see another Unix clone than another bootloader that prints "Hello World".

Re: Errors in tutorial?

Posted: Tue Aug 26, 2014 11:02 am
by no92
iansjack wrote:I'm still not convinced.

I don't think that the people who copy and paste from bare-bones tutorials would be doing the same from, for example, the Linux source code. Mind they'd learn a lot more (before and after) if they did. I'd rather see another Unix clone than another bootloader that prints "Hello World".
I didn't mean that they will copy from Linux, but from slightly advanced hobby OSes (klange's toaruos, for example) or other not-so-advanced OSes. Sorry for that miscommunication.