10

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,498

1 Answers1

15

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
  • 96,466