Binary donot run neither with -m32 nor with 64bit gcc option

0

enter code here------------

system info

Using intel-core i7 processor installed UBUNTU 13.10


code info

My program generates binary : test It links with one shared library : libtest.so libtest.so links with libc.so.6

When tried to run the binary ./test gives the following error:

bash: ./test: cannot execute binary file

I tried to compile with -m32 FLAG made sure libtest.so and test all are in 32bit architecture and linking with libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf756f000)

I am still getting the same error:

bash: ./test: cannot execute binary file

Question:

I neither able run the binary as 64bit or 32bit on x86 machine. I donot understand what else is wrong. Any pointer would be helpful Thank you.

should I install i386-linux-gnu gcc compiler?


More Information:

Below are the gcc I have in my machine

./usr/bin/gcc
./usr/lib/gcc
./usr/share/bash-completion/completions/gcc
./usr/share/doc/gcc-4.8-base/gcc
./usr/share/doc/gcc
./usr/share/doc/gcc-4.7-base/gcc
./usr/libexec/gcc


:/usr/bin# objdump -f gcc

gcc:     file format elf64-x86-64
architecture: i386:x86-64, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x0000000000405ee8

/usr/lib/gcc# ls
i586-mingw32msvc  i686-linux-gnu  x86_64-linux-gnu

/usr/libexec/gcc# ls
i586-mingw32msvc

/usr/bin# objdump -f ld

ld:     file format elf64-x86-64
architecture: i386:x86-64, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x0000000000405b3c

EDIT: SORRY, while copy pasting pasted wrong line The actuall error line is as below :

bash: ./test: cannot execute binary file

Makefile info

src/Makefile :

CC = gcc -m32
ROOT_DIR = .
SUB_DIRS = ./testlib
 CPP_NAME = test

LFLAGS = -fPIC
CFLAGS = -m32 -Wall -shared

$(ROOT_DIR)/%.o : %.c
    -@mkdir -p $(ROOT_DIR)/$(dir $<)
    @$(CC) $(LFLAGS) $(INCPATH) $(LIBPATH) $(LDLIBS) -o $@ -c $<
 EXE = $(ROOT_DIR)/$(CPP_NAME)
  $(EXE): $(OBJS)
    $(CC) $(LFLAGS) $(CFLAGS)  $(LIBPATH) $^ $(LDLIBS) -o $@

 src/testlib/Makefile:

 CC = gcc -m32
 CPP_NAME = test
 LIB_NAME = lib$(CPP_NAME).so
 ROOT_DIR = .
 LIB_DIR = testlib
 OBJS = $(addprefix $(ROOT_DIR)/, $(SRCS:.c=.o))
 CFLAGS+= -fPIC
 LFLAGS += -shared
 $(LIB_DIR)/%.o : %.c
    -@mkdir -p $(ROOT_DIR)/$(dir $<)
    @$(CC)  $(CFLAGS) $(INCPATH) -o $@ -c $<

   SH_OBJ= $(LIB_DIR)/$(LIB_NAME)
   $(SH_OBJ): $(OBJS)
    $(CC) $(CFLAGS) $(LFLAGS) $^ -o $(LIB_NAME)
c
linux
bash
gcc
asked on Stack Overflow May 30, 2014 by cnacy • edited Jun 1, 2014 by cnacy

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0