g++ -m32

Hello,

I am trying to create a 32 bit executable on my 64 bit linux machine.

I have the following makefile:

OBJS = Subtract.o
CC = g++
DEBUG = -g
CFLAGS = -fPIC -Wall -m32 -c $(DEBUG)
LFLAGS = -Wall -m32 $(DEBUG) -L/usr/lib64/gcc/x86_64-suse-linux/4.3 -lstdc++

test:	$(OBJS) 
	$(CC) $(LFLAGS) $(OBJS) -o test

Subtract.o : Subtract.cpp
	$(CC) $(CFLAGS) Subtract.cpp

I am able to create the .o file but not able to create the executable file ‘test’.

I am getting the following link error, even though I have specified the path to the library:

g++ -Wall -m32 -g -L/usr/lib64/gcc/x86_64-suse-linux/4.3 -lstdc++ Subtract.o -o test
/usr/lib64/gcc/x86_64-suse-linux/4.3/…/…/…/…/x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib64/gcc/x86_64-suse-linux/4.3/libstdc++.so when searching for -lstdc++
/usr/lib64/gcc/x86_64-suse-linux/4.3/…/…/…/…/x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib64/gcc/x86_64-suse-linux/4.3/libstdc++.a when searching for -lstdc++
/usr/lib64/gcc/x86_64-suse-linux/4.3/…/…/…/…/x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib64/gcc/x86_64-suse-linux/4.3/libstdc++.so when searching for -lstdc++
/usr/lib64/gcc/x86_64-suse-linux/4.3/…/…/…/…/x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib64/gcc/x86_64-suse-linux/4.3/libstdc++.a when searching for -lstdc++
/usr/lib64/gcc/x86_64-suse-linux/4.3/…/…/…/…/x86_64-suse-linux/bin/ld: cannot find -lstdc++
collect2: ld returned 1 e

Please help.

H

Well for a start a library path with lib64 in it wouldn’t be the right directory.

I see libstdc++.so only in the above mentioned directory, with /lib64 in its path. Do I need to install some other library?

Is there a way I can solve this problem?

Thanks,

H.

If you want to build 32-bit binaries, then you’ll have to install 32-bit libraries.

Thank you.

After searching a bit, I found that I required to install libstdc++43-devel-32bit and gcc43-32bit

H.