Exe file is not running in ubuntu 14 (gcc 4.9.4), which complied at ubuntu 20.04 (gcc 9.3.0)

190 views Asked by At

I have compiled my .c file in ubuntu 20.04 , GCC - 9.3.0 and made its executable. That .exe is running properly in ubuntu 20.04 but I want to transfer to it to Ubuntu 14, gcc-4.9.4 and run it there. But that file is not running in ubuntu 14. Is there any way to run that .exe file in older version of ubuntu?? And please can u explain the reason what is hindering that .exe file to run in ubuntu 14.

Thanks!!!

1

There are 1 answers

0
LSerni On

Usually a .c file, once compiled, does not contain all the code it needs; it contains rather some indicators of where the necessary routines may be found. This allows better code management (you update a library, all files using it will find themselves updated automatically. You have one hundred executables using the same 10-meg library, you end up using 10 MB of disk instead of one gigabyte).

So, if you used a function to read JPEG files, that code would not be in the executable file, but the executable file would contain the information that it requires to load the JPEG library. And would specify it by name. You can see this with the ldd utility.

Since different versions of operating systems might have different libraries, or not have some libraries installed at all, the executable would not run there, as it lacks the means to do so.

You can almost always avoid this by requiring the C compiler to produce a statically linked file, that is, a file that contains all the libraries it needs. You'll end up with a much larger binary file, which will run on many more operating systems (there still needs to be some compatibility in executable format, architecture, etc., but you needn't worry about libraries).