i386:x86-64 architecture of input file `kernel.o' is error

Programming, for all ages and all languages.
Post Reply
Mehmetdev1
Posts: 23
Joined: Fri Apr 01, 2022 10:06 am
Location: Türkiye, Uşak/Merkez

i386:x86-64 architecture of input file `kernel.o' is error

Post by Mehmetdev1 »

i386:x86-64 architecture of input file `kernel.o' is incompatible with i386 output It gives the error, what is the solution, I will post the screenshot and the c++ code.

Code: Select all

void printf(char* str)
{

    unsigned short* VideoMemory = (unsigned short*)0xb8000;

    for(int i = 0; str[i] != '\0'; ++i)
    VideoMemory[i] = (VideoMemory[i] & 0xFF00) | str[i];

}


void kernelMain(void* multiboot_structure, unsigned int magicnumber)
{
    printf("Kapiler İsletim Sistemi");

    while(1);

}
Attachments
İ386 Hata.png
M. Alp
User avatar
iansjack
Member
Member
Posts: 4688
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: i386:x86-64 architecture of input file `kernel.o' is err

Post by iansjack »

Seems pretty self-explanatory.

You are trying to link a 64-bit object file into a 32-bit executable. Not possible.

Presumably you compiled your source with a 64-bit compiler. You either need to tell it to produce 32-bit code or (much better) use a 32-bit cross compiler.
Mehmetdev1
Posts: 23
Joined: Fri Apr 01, 2022 10:06 am
Location: Türkiye, Uşak/Merkez

Re: i386:x86-64 architecture of input file `kernel.o' is err

Post by Mehmetdev1 »

iansjack wrote:Seems pretty self-explanatory.

You are trying to link a 64-bit object file into a 32-bit executable. Not possible.

Presumably you compiled your source with a 64-bit compiler. You either need to tell it to produce 32-bit code or (much better) use a 32-bit cross compiler.
X32 I am using a compiler.
M. Alp
User avatar
iansjack
Member
Member
Posts: 4688
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: i386:x86-64 architecture of input file `kernel.o' is err

Post by iansjack »

You are using a 64-bit compiler (or assembler) to produce kernel.o.
Octocontrabass
Member
Member
Posts: 5515
Joined: Mon Mar 25, 2013 7:01 pm

Re: i386:x86-64 architecture of input file `kernel.o' is err

Post by Octocontrabass »

Mehmetdev1 wrote:X32
Are you talking about the x32 ABI? That's still 64-bit. You need 32-bit.

Ideally, you should use a cross-compiler. I would also suggest working on some easier projects first so you can learn the basics.
Ethin
Member
Member
Posts: 625
Joined: Sun Jun 23, 2019 5:36 pm
Location: North Dakota, United States

Re: i386:x86-64 architecture of input file `kernel.o' is err

Post by Ethin »

I feel like this is becoming a trend -- people think that you can just use a hosted compiler to build an OS. I'm kinda curious why people repeatedly assume this, particularly since it causes so, so many problems and is so painful.
Octocontrabass
Member
Member
Posts: 5515
Joined: Mon Mar 25, 2013 7:01 pm

Re: i386:x86-64 architecture of input file `kernel.o' is err

Post by Octocontrabass »

It's because of all the tutorials that use a hosted compiler.

This code is also from a tutorial. I'm not sure which one, but based on the typos, I'd guess a video.
Post Reply