Author Topic: compile 32 bit asm code with 64 bit linux mint nadia  (Read 13695 times)

Offline jdubya

  • Jr. Member
  • *
  • Posts: 7
compile 32 bit asm code with 64 bit linux mint nadia
« on: November 07, 2013, 03:41:06 AM »
Hello all. First post. I'm new to Linux and currently a student in assembly.  I just want to set up my system so it will compile x86 code in 32 bit. These are the compile errors I'm getting:

/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status

Please keep in mind I am very inexperienced in Linux. Thank you in advance for you help.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: compile 32 bit asm code with 64 bit linux mint nadia
« Reply #1 on: November 07, 2013, 07:20:26 AM »
Funny you should mention it...

I've been running 32-bit Linux for a while, and have some experience with 32-bit asm programming. Recently I upgraded my system to 64 bit - Linux Mint Cinnamon. Now I'm completely lost!

I believe what we have to do is to install 32-bit libraries. I think we want to do this using "apt-get". I'm less sure, but I think what we want is "sudo apt-get install ia32-libs". This seems to "almost" work. It ends up at - of all things - a Microsoft EULA! This is totally unacceptable, but to keep the game going I'll play along and click "yeah, yeah, I accept". The first time I tried this was from a console - no mouse, and hitting "enter" didn't do anything. So just now, I tried it again from a terminal. This time I had mouse, but clicking "ok" didn't do anything, nor did any key combination I tried. Apparently, I am being blocked from installing Linux libraries I want by a Microsoft EULA.

I'm pretty sure my ultimate solution is going to be to flush Linux "Mint" and try another distro - I was running Slackware before and was happy with it. I'm trying to give it a fair trial and see if I can get used to it, but... it's crashed three times on me and popped up a Microsoft EULA more than once. I think it's history. Maybe you'll have better luck with it.

In the meantime, we can write 32-bit code that depends on system calls instead of the C library:
Code: [Select]
nasm -f elf32 myprog.asm
ld -melf_i386 -o myprog myprog.o

Be thankful for small favors!

Best,
Frank


Offline jdubya

  • Jr. Member
  • *
  • Posts: 7
Re: compile 32 bit asm code with 64 bit linux mint nadia
« Reply #2 on: November 07, 2013, 04:55:46 PM »
Funny you should mention it...

I've been running 32-bit Linux for a while, and have some experience with 32-bit asm programming. Recently I upgraded my system to 64 bit - Linux Mint Cinnamon. Now I'm completely lost!

I believe what we have to do is to install 32-bit libraries. I think we want to do this using "apt-get". I'm less sure, but I think what we want is "sudo apt-get install ia32-libs". This seems to "almost" work. It ends up at - of all things - a Microsoft EULA! This is totally unacceptable, but to keep the game going I'll play along and click "yeah, yeah, I accept". The first time I tried this was from a console - no mouse, and hitting "enter" didn't do anything. So just now, I tried it again from a terminal. This time I had mouse, but clicking "ok" didn't do anything, nor did any key combination I tried. Apparently, I am being blocked from installing Linux libraries I want by a Microsoft EULA.

I'm pretty sure my ultimate solution is going to be to flush Linux "Mint" and try another distro - I was running Slackware before and was happy with it. I'm trying to give it a fair trial and see if I can get used to it, but... it's crashed three times on me and popped up a Microsoft EULA more than once. I think it's history. Maybe you'll have better luck with it.

In the meantime, we can write 32-bit code that depends on system calls instead of the C library:
Code: [Select]
nasm -f elf32 myprog.asm
ld -melf_i386 -o myprog myprog.o

Be thankful for small favors!

Best,
Frank

Someone just helped me with that problem Frank.  This package worked for me:
sudo apt-get install gcc-multilib

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: compile 32 bit asm code with 64 bit linux mint nadia
« Reply #3 on: November 07, 2013, 06:41:30 PM »
Thanks, jdubya! And thanks to your friend who helped you with it! That's probably the package I'm looking for. Unfortunately, again it "seemed to be working" but again ended in the accursed EULA. I think MS knows I'm lying about agreeing to their terms and conditions. Maybe if I hit the "ok" button with the big hammer? Don't we have any libraries that don't require permission from MS? I'm trying to be patient with this thing but I'm getting pretty disgusted!

Best,
Frank


Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 429
  • Country: us
Re: compile 32 bit asm code with 64 bit linux mint nadia
« Reply #4 on: November 08, 2013, 01:44:36 AM »
Frank,

RE: the ms eula:
Not sure if apt-get is also attempting to update your fresh install of Mint/Cinnamon fonts.
This may be relevant.
Also, the Software Center app does provide a nice GUI interface to package installation.

Offline 0xFF

  • Jr. Member
  • *
  • Posts: 15
Re: compile 32 bit asm code with 64 bit linux mint nadia
« Reply #5 on: November 08, 2013, 11:55:13 AM »
Ah yeah guys I had a similar problem on ubuntu (64bit) when using gcc to link (was using printf to print decimals). At the time I was trying to decide whether to learn 32 bit asm to keep compatible with all cpus, and most of the books on asm, or go for 64 bit to know the future standard and take advantage of the full power of my chipset. Ultimatel I figure I should learn both, but man, I could not get that bugger to compile!

Yeah, on a 64 bit system you have to get the 32 bit libraries, at least for gcc. I can't quite remember whether I needed it to link with ld though, ubuntu may have had those.

What's mint like? I love ubuntu, but I'm interested in the various flavours out.

Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 429
  • Country: us
Re: compile 32 bit asm code with 64 bit linux mint nadia
« Reply #6 on: November 08, 2013, 04:50:25 PM »
Ah yeah guys I had a similar problem on ubuntu (64bit) when using gcc to link (was using printf to print decimals). At the time I was trying to decide whether to learn 32 bit asm to keep compatible with all cpus, and most of the books on asm, or go for 64 bit to know the future standard and take advantage of the full power of my chipset. Ultimatel I figure I should learn both, but man, I could not get that bugger to compile!

Correct answer, learn both!  32-bit will still be relevant for quite a while although x64 is clearly the mainstream now and will be for a long long time.

Yeah, on a 64 bit system you have to get the 32 bit libraries, at least for gcc. I can't quite remember whether I needed it to link with ld though, ubuntu may have had those.

Most Linux distributions that target the end-user desktop environment ( read non-developer ) will most likely not have everything that a programmer needs.

What's mint like? I love ubuntu, but I'm interested in the various flavours out.

Mint makes some great desktop systems and you'll have no problem since both Mint and Ubuntu are both Debian-based.  However, if you don't want a distribution based on a distribution based on yet another distribution and want to give Mint a try then I'd recommend Linux Mint Debian Edition ( LMDE ).  Use either a live CD or VM to check it out first - will obviously not run at optimal speeds this way but does make for a quick test.  I've used both the Mate and Cinnamon desktops and I like both ( I personally find the Unity and Gnome 3 shells revolting ).  If you're going to install LMDE read the forums though before you update all the software with the latest changes.  There is an issue with UP7.