bash: ./a.out: cannot execute binary file: Exec format error

Asked by xin-xu on 2016-11-14

I tried to install WRF with this test to check fortran_C_test, my computer is i686 on Ubuntu 16. 04LTS there are 7 tests for Fortran_C_test and pass 6 of them, step 4 occur the problem as above.

Please anyone who can help me in this case.

Thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu glibc Edit question
Assignee:
No assignee Edit question
Solved by:
xin-xu
Solved:
2016-11-18
Last query:
2016-11-18
Last reply:
2016-11-15

What build options are you using please?

xin-xu (xin-xu) said : #2

would you please help me how can I find my build option? I downloading 3.8 WRFV3 on my ubuntu.

xin-xu (xin-xu) said : #3

    gcc -c -m64 TEST_4_fortran+c_c.c
    gfortran -c -m64 TEST_4_fortran+c_f.f90
    gfortran -m64 TEST_4_fortran+c_f.o TEST_4_fortran+c_c.o
    ./a.out
when I try to make test on this process with ./a.out, the error will occur like that. binery file wrong.

thanks

xin-xu (xin-xu) said : #4

uname -a : Linux sam-pc 4.4.0-47-generic #68-Ubuntu SMP Wed Oct 26 19:39:59 UTC 2016 i686 i686 i686 GNU/Linux

xin-xu (xin-xu) said : #5

a.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=ba350a9401b1cf6c87e282c9d14345b1047d8032, not stripped

The reason for the error can be found in your last 2 posts (post #4 and post #5)

You are trying to execute a 64-bit LSB executable using a 32-bit kernel (4.4.0-47-generic #68-Ubuntu SMP Wed Oct 26 19:39:59 UTC 2016 i686). i686 means 32-bit computing, NOT 64-bit.

You would need a 64-bit kernel (using a 64-bit GNU/Linux distribution) to do 64-bit testing....

xin-xu (xin-xu) said : #7

so do I need to reinstall ubuntu ? or create 64-bit kernel?
thanks

xin-xu (xin-xu) said : #8

when I changed to 32bit run 64 bit as this link:
http://www.unixmen.com/enable-32-bit-support-64-bit-ubuntu-13-10-greater/

it shows like this under belows:

sam@sam-pc:~/test1$ gfortran -m64 TEST_4_fortran+c_f.o TEST_4_fortran+c_c.o
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i686-linux-gnu/5/libgfortran.so when searching for -lgfortran
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i686-linux-gnu/5/libgfortran.a when searching for -lgfortran
/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status

I think it might be wrong soft link.

right?

Try:

sudo apt-get install libgfortran-5-dev libx32gfortran-5-dev

Then retry

xin-xu (xin-xu) said : #10

thanks !

I found the problem. My friend helped me to reinstall the ubuntu16 on the second time and he downloaded wrong version with i386, my software WRF3.8 should run on amd64...

Thanks agian.

Isn't that what I wrote in post #6??

"You would need a 64-bit kernel (using a 64-bit GNU/Linux distribution) to do 64-bit testing...."

In any case, you cannot install a 64-bit kernel on top of a 32-bit GNU/Linux distribution.