Ask Your Question
1

Having trouble to compile a 32 bits program on fedora 21(64bits)

asked 2015-02-04 20:44:44 -0500

jackkkkdtz gravatar image

I'm having an assembly course in my university. Our prof ask us the download some code from http://www.drpaulcarter.com/pcasm/index.php (example code for Linux, at the bottom of the page )

Since it's 32 bits program so i add -m32 after gcc and g++

but i still have trouble compiling the program. Can anyone pls help me ? thank you in advance

gcc -c  driver.c
driver.c:3:1: warning: ‘cdecl’ attribute ignored [-Wattributes]
 int PRE_CDECL asm_main( void ) POST_CDECL;
 ^
nasm -f elf prime.asm
nasm -f elf -d ELF_TYPE asm_io.asm
gcc  -oprime driver.o prime.o asm_io.o
/usr/bin/ld: i386 architecture of input file `prime.o' is incompatible with i386:x86-64 output
/usr/bin/ld: i386 architecture of input file `asm_io.o' is incompatible with i386:x86-64 output
collect2: error: ld returned 1 exit status
Makefile:28: recipe for target 'prime' failed
make: *** [prime] Error 1
edit retag flag offensive close merge delete

Comments

It has been a long time since I've dealt with this, but from what I remember it involves installing a bunch of compatibility library packages. If you don't get a good answer to this question, maybe consider alternatives? Virtual machines run so nice and smooth on Fedora these days, much smoother than gunking up your system with a bunch of rpms that may or may not do what you want.

Woland gravatar imageWoland ( 2015-02-04 23:54:27 -0500 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2015-02-06 16:00:22 -0500

sinic gravatar image

GCC tries to link your 32-bit object files against certain 32-bit libraries. Those aren't present by default on a 64-bit system, so you need to install them: yum install glibc-devel.i686 libgcc.i686

Now you can build your source code, but don't forget the 32-bit flag:

gcc -c -m32 driver.c
nasm -f elf prime.asm
nasm -f elf -d ELF_TYPE asm_io.asm
gcc -m32 -oprime driver.o prime.o asm_io.o
edit flag offensive delete link more
0

answered 2015-02-09 07:29:26 -0500

AdmiralFlush gravatar image

The easy way is to create a 32 bit linux environment to compile the 32 bit linux things. The easiest way is to get two environments. Get a virtual machine app like KVM or VirtualBox or WMware and work in a 32 bit environment. OR Try LXC to create a 32 bit container to compile 32 bit linux things. It is a little more complicated than just using virtualbox with a 32bit linux environment.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2015-02-04 20:44:44 -0500

Seen: 2,541 times

Last updated: Feb 09 '15