Run program compiled in Ubuntu in centos

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Run program compiled in Ubuntu in centos
# 1  
Old 07-29-2016
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 Smilie
# 2  
Old 07-29-2016
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.

Last edited by jim mcnamara; 07-29-2016 at 09:58 AM..
This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 09-13-2016
Thank you, I was able to get the net on the centos server so can compile there. Thank you Smilie.
# 4  
Old 09-13-2016
Hi.

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

One does this by using the link option:
Code:
       -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
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Web Development

Building LAMP server from scratch (build a server with compiled LAMP from CentOS mini)

Hello everyone, I would like to setup a lamp server from a minimal distro and to compile PHP, MySQL and Apache myself. I have chosen CentOS minimal for the OS and I am trying to build the stack by hand... But well, it appears I need some help! First: I am looking for good and recent... (3 Replies)
Discussion started by: freddie50
3 Replies

2. Programming

Using ANSI color codes in gcc compiled program

I have put some yellow color codes and works well. I call the funstion using print_usage(stderr, 0); I would like to know if there is any way, to store the ansi color codes in variables and then call them inside fprintf. Or have a format followed by the strings I want to output. ... (5 Replies)
Discussion started by: kristinu
5 Replies

3. Solaris

Issue in pro*C program compiled in solaris 10

Hi, We upgraded our servers from solaris 9 to 10. We recompiled all the Pro*C programs with the new oracle version as well. Oracle is 11g. We are facing core dump with the below error for certain executions. But when we are placing new statements between the error fucntion we get junk values to... (1 Reply)
Discussion started by: saroopkris85
1 Replies

4. Homework & Coursework Questions

Calling compiled C program with Perl program

Long story short: I'm working inside of a Unix SSH under a bash shell. I have to code a C program that generates a random number. Then I have to call the compiled C program with a Perl program to run the C program 20 times and put all the generated random #s into a text file, then print that text... (1 Reply)
Discussion started by: jdkirby
1 Replies

5. UNIX for Dummies Questions & Answers

Making a program compiled on Unix (HPUX) work on Linux

I am trying to make an application which works on unix to work on linux. I already tried copying the binary files and start it up but I am getting an error stating "Cannot execute binary file". Then I tried to recompile but i am getting an error whenever I tried to recompile. I am getting the... (1 Reply)
Discussion started by: khestoi
1 Replies

6. Shell Programming and Scripting

Problem with `cat` the compiled output of C program in unix

Hello All, I have coded a C program which looks something like below... (program name: test.c) #include<stdio.h> main() { int dist,dm,dcm; printf(" Enter the distance between 2 cities in KM : "); scanf("%d",&dist); dm=dist*1000; dcm=dist*10; printf("Distance between 2 cities in... (6 Replies)
Discussion started by: smarty86
6 Replies

7. UNIX for Advanced & Expert Users

cannot run c compiled programs

iam in the way of making graphics using SDL.i copied from cd usign mount -a /cdrom cd /cdrom cp SDL-1.2.11.tar.gz /usr/test cd /usr/test gunzip SDL-1.2.11.tar.gz tar -xf SDL-1.2.11.tar cd SDL-1.2.11 ./configure ... ... it stops at checking whether the c compiler... (4 Replies)
Discussion started by: kumarangopi
4 Replies

8. Programming

How to use a .exe with a compiled program.

I am confused about how to use a .exe file in unix along with a compiled C++ program. I've been using emacs and I compiled with g++, but I have no idea how that relates to use with a .exe. (1 Reply)
Discussion started by: adamsy
1 Replies

9. Programming

Running a compiled Program

Just getting into the Unix command line programming and am unable to run any program I write. I am using a Makefile and the source is compiling but when I enter the name of the output file I get back: bash: lab01exe.out: command not found I'm sure I am just dooing something simple... (2 Replies)
Discussion started by: Krebsbac
2 Replies
Login or Register to Ask a Question