[SOLVED]Errors in tutorial?

All about the OSDev Wiki. Discussions about the organization and general structure of articles and how to use the wiki. Request changes here if you don't know how to use the wiki.
Post Reply
User avatar
bashcommando
Member
Member
Posts: 62
Joined: Mon Jan 06, 2014 4:23 pm

[SOLVED]Errors in tutorial?

Post 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'
Last edited by bashcommando on Tue Jan 20, 2015 3:46 pm, edited 1 time in total.
Building an operating system is like building an airplane, you don't want it to crash.
User avatar
Bender
Member
Member
Posts: 449
Joined: Wed Aug 21, 2013 3:53 am
Libera.chat IRC: bender|
Location: Asia, Singapore

Re: Errors in tutorial?

Post 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.
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)
User avatar
bashcommando
Member
Member
Posts: 62
Joined: Mon Jan 06, 2014 4:23 pm

Re: Errors in tutorial?

Post 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.
Building an operating system is like building an airplane, you don't want it to crash.
klange
Member
Member
Posts: 679
Joined: Wed Mar 30, 2011 12:31 am
Libera.chat IRC: klange
Discord: klange

Re: Errors in tutorial?

Post 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.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Errors in tutorial?

Post 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.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
bashcommando
Member
Member
Posts: 62
Joined: Mon Jan 06, 2014 4:23 pm

Re: Errors in tutorial?

Post 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.
Building an operating system is like building an airplane, you don't want it to crash.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Errors in tutorial?

Post 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.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Errors in tutorial?

Post 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.
no92
Member
Member
Posts: 307
Joined: Wed Oct 30, 2013 1:57 pm
Libera.chat IRC: no92
Location: Germany
Contact:

Re: Errors in tutorial?

Post 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.
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Errors in tutorial?

Post 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".
no92
Member
Member
Posts: 307
Joined: Wed Oct 30, 2013 1:57 pm
Libera.chat IRC: no92
Location: Germany
Contact:

Re: Errors in tutorial?

Post 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.
Post Reply