8

I am trying to run an executable file called i686-elf-gcc in my Kali Linux that I downloaded from this repository. It's a cross-compiler. The problem is that even though the terminal and a script that I wrote can both see that the file exists, when its time to actually execute it I get No such file or directory error.Here is an image that explains it:

enter image description here

I have also to say that I have granted the necessary permissions to the executable.

Thushi
  • 9,388
  • 4
  • 29
  • 43
blacklister
  • 93
  • 1
  • 1
  • 3
  • 1
    Please paste the text instead of attaching a picture. – Thushi Dec 29 '17 at 11:20
  • 1
    You are already logged in as `root`. Can you please explain me the reason for running the command with `sudo`? – Thushi Dec 29 '17 at 11:22
  • 5
    For sure there is no `i386*` file. – jimmij Dec 29 '17 at 11:22
  • Also the file you are executing and the file you are checking both are different – Thushi Dec 29 '17 at 11:23
  • Also please check the executable bit for `i686-elf-gcc` file – Thushi Dec 29 '17 at 11:24
  • Sorry guys, i am trying to fix this for about 2 hours now and i messed things up in the photo. Even when i typed "i686-elf-gcc" i got the same result: i686-elf-gcc: cannot open 'i686-elf-gcc' (No such file or directory). I just managed to fix it by installing libc6-i386 package(apt-get install libc6-i386). Thank you all of you for your help and sorry for the trouble !! I hope it may help anyone that ends up with the same problem trying to follow the OSDev tutorial. – blacklister Dec 29 '17 at 11:30
  • 3
    It will help hardly anyone. You've posted a non-indexable image instead of text, not given a correct description of the problem, handwaved over what you did to fix it, and not even supplied your answer as an actual answer. – JdeBP Dec 29 '17 at 13:06
  • 1
    [Don't post images of text](https://unix.meta.stackexchange.com/questions/4086/psa-please-dont-post-images-of-text) – Gilles 'SO- stop being evil' Dec 29 '17 at 14:59
  • 1
    [Duplicate question](https://unix.stackexchange.com/questions/13391/getting-not-found-message-when-running-a-32-bit-binary-on-a-64-bit-system). Also [read this](https://unix.stackexchange.com/questions/399626/why-is-kali-linux-so-hard-to-set-up-why-wont-people-help-me). – Gilles 'SO- stop being evil' Dec 29 '17 at 14:59

1 Answers1

13

Typically, the "unable to execute... No such file or directory" means that either the executable binary itself or one of the libraries it needs does not exist. Libraries can also need other libraries themselves.

To see a list of libraries required by a specified executable or library, you can use the ldd command:

$ ldd /usr/local/bin/i686-elf-gcc

If the resulting listing includes lines like

<library name> => not found

then the problem can be fixed by making sure the mentioned libraries are installed and in the library search path.

In this case, the libraries might be at /usr/local/lib or /usr/local/lib64, but for some reason that directory is not included in the library search path.

If you want the extra libraries to be available for specific programs or sessions only, you could use the LD_LIBRARY_PATH environment variable to identify the extra path(s) that should be searched for missing libraries. This will minimize the chance of conflicts with the system default libraries.

But if you want to add a library directory to the system default library search path, you should add it to /etc/ld.so.conf file, or create a /etc/ld.so.conf.d/*.conf file of your choice and then run the ldconfig command as root to update the library search cache.

For example, if the missing libraries are found in /usr/local/lib64 and /etc/ld.so.conf.d directory exists, you might want to create crosscompiler.conf file like this:

# echo "/usr/local/lib64" > /etc/ld.so.conf.d/crosscompiler.conf
# ldconfig
telcoM
  • 87,318
  • 3
  • 112
  • 232