Run program compiled in Ubuntu in centos

Will a program compiled in ubuntu 14.04 execute in Centos 7 ? That is to say a tarball or zip is downloaded from github and extracted, compiled, and make is all done in ubuntu 14.04 , can I mv the program from ubuntu 14.04 to Centos 7 , add it to path in Centos 7 . And run it? Thank you :slight_smile:

I would say the probability of success is low. Centos is really redhat Linux, redux.

A way to verify:
Make sure your LD_LIBRARY_PATH lets you run the file on Ubuntu! First.

Next. Use the ldd command on the executable on the parent Ubuntu box. Save the output.
ex: ldd myprogram > keepme.txt

Next. Run the same ldd test on Centos. You may have to dink with your environment to get everything to show up. Compare the output with keepme.txt, or if you cannot find all of the library entries then - cannot run.

I think you will probably find a lot of missing shared libraries, meaning: Cannot run

Why can you not compile on centos? You can also compile on Ubuntu using static linking which places everything, libraries and all in the file. This has a really much better chance of running correctly. The only downside is the executable file will be huge.

1 Like

Thank you, I was able to get the net on the centos server so can compile there. Thank you :).

Hi.

One solution is to take your libraries with you, at least in a limited sense,

One does this by using the link option:

       -static
           Do not link against shared libraries.  This is only meaningful on
           platforms for which shared libraries are supported.  The different
           variants of this option are for compatibility with various systems.

-- excerpt from man ld, q.v.

before you transfer the executable to another platform (a similar platform, I hasten to add). I have done this several times without problems.

A draw back is that the resulting executable will be, of course, far larger in size compared to its dynamic version.

Best wishes ... cheers, drl