No such file or directory? But the file exists!
I’ve downloaded a game (Shank) but the bin file doesn’t run. The error that is shown when I try to launch the executable is:
bash: ./shank-linux-120720110-1-bin: No such file or directory
Thank you for your reply. I’ve done the command you said Agent86 but I have the same result. I’ve downloaded also the .deb file but there is a problem too. I don’t know what problem has this game.
Please confirm whether you’re running a 64-bit installation (that’s the most common case for this problem).
9 Answers 9
You’re probably trying to run a 32-bit binary on a 64-bit system that doesn’t have 32-bit support installed.
There are three cases where you can get the message “No such file or directory”:
- The file doesn’t exist. I presume you’ve checked that the file does exist (perhaps because the shell completes it).
- There is a file by that name, but it’s a dangling symbolic link.
- The file exists, and you can even read it (for example, the command file shank-linux-120720110-1-bin displays something like “ELF 32-bit LSB executable …”), and yet when you try to execute it you’re told that the file doesn’t exist.
The error message in this last case is admittedly confusing. What it’s telling you is that a key component of the runtime environment necessary to run the program is missing. Unfortunately, the channel through which the error is reported only has room for the error code and not for this extra information that it’s really the runtime environment that’s to blame. If you want the technical version of this explanation, read Getting “Not found” message when running a 32-bit binary on a 64-bit system.
The file command will tell you just what this binary is. With a few exceptions, you can only run a binary for the processor architecture that your release of Ubuntu is for. The main exception is that you can run 32-bit (x86, a.k.a. IA32) binaries on 64-bit (amd64, a.k.a. x86_64) systems.
In Ubuntu up to 11.04, to run a 32-bit binary on a 64-bit installation, you need to install the ia32-libs package . You may need to install additional libraries (you’ll get an explicit error message if you do).
Since 11.10 (oneiric) introduced multiarch support, you can still install ia32-libs , but you can choose a finer-grained approach, it’s enough to get libc6-i386 (plus any other necessary library).
ELF Binary Error Unix («./X No such file or directory»)
I have compiled it on Ubuntu 32 Bit and now I want to run it on an Unix i386 virtual machine with Linux Kernel 3.4.0
ldd on the Unix image where it’s not working:
bash-4.3# ldd insane insane: -lc.6 => not found
ldd insane linux-gate.so.1 => (0xb7784000) libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb75b5000) /lib/ld-linux.so.2 (0x80086000)
bash-4.3# ls /usr/lib/ bc liblua.so cawf liblua.so.5 crontab liblua.so.5.3 crt0.o liblua_pic.a crtbegin.o liblutok.a crtbeginS.o liblutok.so crtbeginT.o liblutok.so.2 crtend.o liblutok.so.2.0 crtendS.o liblutok_pic.a crti.o liblwip.a crtn.o liblwip_pic.a fonts liblzma.a gcrt0.o liblzma.so keymaps liblzma.so.2 libarchive.a liblzma.so.2.0 libarchive.so liblzma_pic.a libarchive.so.3 libm.a libarchive.so.3.1 libm.so libarchive_pic.a libm.so.0 libasyn.a libm.so.0.11 libasyn_pic.a libm387.a libatf-c++.a libm387.so libatf-c++.so libm387.so.0 libatf-c++.so.1 libm387.so.0.1 libatf-c++.so.1.0 libm387_pic.a libatf-c++_pic.a libm_pic.a libatf-c.a libmagic.a libatf-c.so libmagic.so libatf-c.so.0 libmagic.so.5 libatf-c.so.0.0 libmagic.so.5.1 libatf-c_pic.a libmagic_pic.a libaudiodriver.a libmenu.a libaudiodriver_pic.a libmenu.so libbdev.a libmenu.so.6 libbdev_pic.a libmenu.so.6.0 libbfd.so.13 libmenu_pic.a libbfd.so.13.0 libminc.a libblacklist.a libminixfs.a libblacklist.so libminixfs_pic.a libblacklist.so.0 libmj.a libblacklist.so.0.0 libmj.so libblacklist_pic.a libmj.so.1 libblockdriver.a libmj.so.1.0 libblockdriver_pic.a libmj_pic.a libbz2.a libmthread.a libbz2.so libmthread.so libbz2.so.1 libmthread.so.0 libbz2.so.1.1 libmthread.so.0.0 libbz2_pic.a libmthread_pic.a libc++.a libnetdriver.a libc++.so libnetdriver_pic.a libc++.so.1 libnetpgp.a libc++.so.1.0 libnetpgp.so libc++_pic.a libnetpgp.so.3 libc.a libnetpgp.so.3.0 libc.so libnetpgp_pic.a libc.so.12 libnetpgpverify.a libc.so.12.197 libnetpgpverify.so libc_pic.a libnetpgpverify.so.4 libchardriver.a libnetpgpverify.so.4.0 libchardriver_pic.a libnetpgpverify_pic.a libcrypt.a libnetsock.a libcrypt.so libnetsock_pic.a libcrypt.so.1 libopcodes.so.6 libcrypt.so.1.0 libopcodes.so.6.0 libcrypt_pic.a libpci.a libcrypto.a libpci.so libcrypto.so libpci.so.2 libcrypto.so.8 libpci.so.2.1 libcrypto.so.8.4 libpci_pic.a libcrypto_pic.a libprop.a libcurses.a libprop.so libcurses.so libprop.so.1 libcurses.so.7 libprop.so.1.1 libcurses.so.7.0 libprop_pic.a libcurses_pic.a libpuffs.a libddekit.a libpuffs.so libddekit_pic.a libpuffs.so.2 libddekit_usb_client.a libpuffs.so.2.0 libddekit_usb_client_pic.a libpuffs_pic.a libddekit_usb_server.a librefuse.a libddekit_usb_server_pic.a librefuse.so libdes.a librefuse.so.2 libdes.so librefuse.so.2.0 libdes.so.8 librefuse_pic.a libdes.so.8.2 librmt.a libdes_pic.a libsaslc.a libdevman.a libsaslc.so libdevman_pic.a libsaslc.so.0 libedit.a libsaslc.so.0.0 libedit.so libsaslc_pic.a libedit.so.3 libsffs.a libedit.so.3.1 libsffs_pic.a libedit_pic.a libsqlite3.a libelf.a libsqlite3.so libelf.so libsqlite3.so.1 libelf.so.1 libsqlite3.so.1.2 libelf.so.1.0 libsqlite3_pic.a libelf_pic.a libssl.a libevent.a libssl.so libevent.so libssl.so.10 libevent.so.4 libssl.so.10.5 libevent.so.4.0 libssl_pic.a libevent_openssl.a libsys.a libevent_openssl.so libsys.so libevent_openssl.so.4 libsys.so.0 libevent_openssl.so.4.0 libsys.so.0.0 libevent_openssl_pic.a libsys_pic.a libevent_pic.a libtermcap.a libexec.a libtermcap.so libexec_pic.a libtermcap.so.0 libexecinfo.a libtermcap.so.0.6 libexecinfo.so libtermcap_pic.a libexecinfo.so.0 libterminfo.a libexecinfo.so.0.0 libterminfo.so libexecinfo_pic.a libterminfo.so.1 libexpat.a libterminfo.so.1.0 libexpat.so libterminfo_pic.a libexpat.so.2 libtermlib.a libexpat.so.2.1 libtermlib.so libexpat_pic.a libtermlib.so.0 libfetch.a libtermlib.so.0.6 libfetch.so libtermlib_pic.a libfetch.so.3 libtimers.a libfetch.so.3.0 libtimers_pic.a libfetch_pic.a libusb.a libfl.a libusb_pic.a libform.a libutil.a libform.so libutil.so libform.so.6 libutil.so.7 libform.so.6.0 libutil.so.7.23 libform_pic.a libutil_pic.a libfsdriver.a libvassert.a libfsdriver_pic.a libvboxfs.a libgcc_s.a libvboxfs_pic.a libgcc_s.so libvirtio.a libgcc_s.so.1 libvirtio_pic.a libgcc_s.so.1.0 libvtreefs.a libhgfs.a libvtreefs_pic.a libhgfs_pic.a libz.a libinputdriver.a libz.so libinputdriver_pic.a libz.so.1 libkvm.a libz.so.1.0 libkvm.so libz_pic.a libkvm.so.6 lua libkvm.so.6.0 pkgconfig libkvm_pic.a pwdauth libl.a security liblua.a
bash-4.3# ./insane bash: ./insane: No such file or directory
«No such file or directory» error when trying to execute a binary [duplicate]
nasm -f elf64 test64.asm successfully creates test64.o and ld -s -o hello test64.o -lc creates an executable file, but when I try to run it, I get a «No such file or directory» error.
Regarding the edit — I’m adding Linux tag back in. This code, is compiled with NASM; is about running executables in a Linux like environment (confirmed with the fact we are tagged as Ubuntu); and the linker target is ELF64. I would suggest that given that information, that Linux is still an applicable tag because it is a question about software development in a Linux environment, and to fix the issue will require a Linux specific solution.
2 Answers 2
1) You’re using the wrong calling convention for printf . The arguments were passed in registers, not on the stack: https://en.wikipedia.org/wiki/X86_calling_conventions#System_V_AMD64_ABI. Also, printf needs a value in EAX (0 in your case).
is wrong. But if you use the 64-bit-Linux-syscall
mov edi, 0 ; return 0 (success) mov eax, 60 ; sys_exit syscall
you will not see the output of printf , because it is buffered and the buffer won’t be flushed. You can call fflush(0) or exit .
3) To use C functions in Linux you have to link with a special loader ( /lib64/ld-linux-x86-64.so.2 ). I just don’t know if it is installed by default.
4) push val1 pushes the address of val1, not its value. Use brackets to get the values. I guess you wanted just load a 32-bit DWORD into a 64-bit register. You can directly load the DWORD into a 32-bit register (the upper part of the 64-bit-register will be cleared) or use movsx for a signed operation.
section .data fmt db `%d\n`,0 ; backticks for '\n' val1 dd 23 val2 dd 9 val3 dd 7 section .text global _start extern printf, exit _start: movsx rax, dword [val1] ; signed dword to signed qword movsx rbx, dword [val2] imul rax, rbx mov ebx, [val3] ; unsigned dword into RBX add rax, rbx mov [val1], rax mov rdi, fmt ; string pointer mov rsi, [val1] ; immediate value xor eax, eax ; no vector registers used call printf xor edi, edi call exit
nasm -f elf64 test64.asm
ld -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o test64 test64.o -lc
./test64
executing binary file: file not found
I know there are similar questions out there, but I haven’t found a solution nor this exact case. The binary was built on Arch Linux using its GCC 4.7. The package works fine on the build system. The commands below were executed on:
Linux vbox-ubuntu 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
The file in question is located here. It’s a Linux 64-bit to Windows 64-bit cross-compiler. Untarring it to ~/ gives a single ~/mingw64 directory which contains everything needed. When I try to run ~/mingw64/x86_64-w64-mingw32/bin/as this is what I get:
bash: /home/ruben/mingw64/x86_64-w64-mingw32/bin/as: No such file or directory
/home/ruben/mingw64/x86_64-w64-mingw32/bin/as: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0x0b8e50955e7919b76967bac042f49c5876804248, not stripped
linux-vdso.so.1 => (0x00007fff3e367000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f2ceae7e000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2ceaac1000) /lib/ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 (0x00007f2ceb0a8000)
I am truly at a loss. Any help is much appreciated. EDIT: Some more details: The build system is Arch Linux (currently glibc 2.16). The output of ls -l is:
-rwxr-xr-x 2 ruben users 1506464 11 aug 23:49 /home/ruben/mingw64/bin/x86_64-w64-mingw32-as
Version References: required from libz.so.1: 0x0827e5c0 0x00 05 ZLIB_1.2.0 required from libc.so.6: 0x0d696917 0x00 06 GLIBC_2.7 0x06969194 0x00 04 GLIBC_2.14 0x0d696913 0x00 03 GLIBC_2.3 0x09691a75 0x00 02 GLIBC_2.2.5
linux-vdso.so.1 => (0x00007fff225ff000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fd525c71000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd5258b4000) /lib/ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 (0x00007fd525e9b000) Version information: /home/ruben/mingw64/x86_64-w64-mingw32/bin/as: libz.so.1 (ZLIB_1.2.0) => /lib/x86_64-linux-gnu/libz.so.1 libc.so.6 (GLIBC_2.7) => /lib/x86_64-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.3) => /lib/x86_64-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libz.so.1: libc.so.6 (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libc.so.6: ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2 ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
The tested other OSes are Fedora 17 (glibc 2.15) and Ubuntu 12.04 (eglibc 2.15). Both zlib and glibc version requirements are met.