How to compile a linux app to run on a shared web server - linux

I am trying to get a small C application to run on my web server. The web hosting company is HostGator and we have their least-expensive plan 'Hatchling'
Unfortunately this particular plan does not provide access to a compiler, which means I'll need to build it on a similar machine to that server and transfer the executable there.
My question is how 'close' do I have to get to the Linux distribution on that web server for this to work? I currently have a recent Ubuntu in a VM and would like to use it for this process but maybe some complex differences in how Ubuntu compiler chain is built versus what can work on the web server are too great?
Would I need to install the CentOS release 6.5 they use and compile on that?
What do you recommend I do to attack this problem?
John,
P.S. Hostgator runs 'CentOS release 6.5 (Final)' and /proc/version returns "Linux version 3.2.52 (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) )"

It is worth checking that the architecture is the same e.g. Intel - 32bit or 64bit. In theory 32bit will work on a 64bit architecture as long as supporting libraries have been installed.
Dependancies are the other challenge you will have.
Versions of GCC and Kernel versions do not matter too much.

Related

Can you build Rust for old (Redhat 5 vintage) Linux?

Redhat 5 has the required 2.6.18 kernel but not the latest glibc, g++ and certainly no clang. The binary distribution doesn't run, complaining about glibc version.
Has anyone made an attempt to back port to old Linux? I could imagine cobbling together a frankensystem with an old kernel but new compilers and try to compile against old glibc or statically compile in some of new glibc but it seems like a fraught course.
Just wondering if anyone has tried and can offer guidance?
I'm thinking there must be a distro setup to do such builds. Anaconda, for example, includes lots of new technologies but works fine on Redhat 5. I wonder how they build it?
Update: Once you get some newer compilers working on RHEL5 it's still not possible to build Rust because it depends on a working binary of itself to bootstrap. See: https://github.com/rust-lang/rust/issues/9545#issuecomment-54865031
Anaconda packages are built against CentOS 5 (which is equivalent to Redhat 5). The important thing is to compile against an old enough glibc, as it is strictly forward compatible (as you saw). The version of glibc is typically tied to the version of the distro, so your best bet is to make a VM with CentOS 5 and build on that.
The version of the compiler used is not as important, and in fact in some cases it is necessary to use a newer compiler than the old one that comes with the system to get things to work. I have gcc 4.8 built for CentOS 5 which you can get with conda (conda install -c asmeurer gcc).
I hit this very issue this weekend, because Skylight supports Linux 2.6.18, including CentOS 5.10, and we use Rust in our agent.
Alex Crichton of the Rust core team was kind enough to get this working again by using CentOS 5.10 boxes for the build, which uses glibc 2.5 and Linux 2.6.18.

Is it possible to build packages for multiple versions of Red hat Linux on a single server?

I have a set of programs for analyzing radiation data and I want to build packages for Red Hat Linux versions 4.x - 6.x. Is it possible to build these packages on a single build server running a single version of Red Hat Linux or do I need to build the version 4.x package on a server running version 4.x and the version 5.x package on a server running version 5.x?
If I can build packages for several versions on a single server, must that server be running the newest version or the oldest version of the OS?
You need to build toolchain for different OS environments (toolchain for Redhat 4.x and 5.x) and with in toolchain you can build packages for specific OS. toolchain is like a chroot environments.
You can create multiple Virtual machine using KVM and build many version of packages using single node..
You can use UML (User Mode Linux) which is quite interesting... Check out following Link
http://uml.devloop.org.uk/howto.html
You can build your packages in a chroot jail. You can use mach to do so.
Here's a tutorial on building packages with mach you could refer to, though it may be outdated.

Compiling a Linux program for ARM architecture - running on a host OS

I have a ARM Coretex-A8 development board from Freescale (i.MX53) running Linux Ubuntu. It boots up just fine and I can access the system with mouse/keyboard/terminal.
To get started I would like to make an application running on the board inside the host OS, just as you do when you run application on your PC.
My problem is to compile my test program, using toolchains like YAGARTO which is based on gcc i end up in trouble with the linking bacause I have not defined any startup script.
I find lot of information on building "bare metal" configurations (inluding compiling the kernel and make load and link scripts), but not anything usefull for making a application running on a host OS.
My development environment is running on Windows 7. I also have the option to run on Linux X86, but i doubt this whould help me making ARM applications.
For ARM-Linux application development the preferable choice is a Linux Host(x86) machine with a ARM toolchain installed in it. In Ubuntu Desktop machine you can use the following command to install ARM toolchain:
apt-get install gcc-arm-linux-gnueabi
After toolchain installation you can use the following command for cross compilation:
gcc-arm-linux-gnueabi-gcc -o hello hello.c
Using this toolchain you can cross-compile your C program using Standard C library without the need of startup code. Applications can be cross-compiled at your Host Linux(x86) platform and run on Target Linux(ARM) platform.
Windows version of ARM-Linux Toolchain is also available. You can get it from here.
Linaro Developers Wiki - an open organization focused on improving Linux on ARM, will be a good reference for your work.

Qt-Based Application binary compatiblity issue due to glibc version

I am developing and building my QT-based application on ubuntu 12.04 LTS which uses glibc 2.15. The binary version of the application runs on some linux distributions but not on others. One of the main problem is compatibility issues caused by different versions of glibc with different linux distributions. For example, it doesn't work on centos which uses glibc 2.12 or wary pup which uses glibc 2.10.
Is there anyway to build QT against a lower version of glibc on ubuntu 12.04 LTS? Or do I have to switch to a lower version of Ubuntu to do all the devleopment?
Yes, the easiest way to support old glibc is to build the applications on a older setup.
I have no problem building a complex Qt application (including the use of QtWebKit) on CentOS 5.8 (with gblic 2.5). The application runs fine on Ubuntu, as old as 8.04 (Hardy Heron).

Compile for CentOS on Ubuntu

Can I install an older version of gcc/g++ (4.1.3) on the latest Ubuntu (which comes with 4.4.3) and use it to compile a .so which should run on CentOS? The binary compiled with the Ubuntu version of gcc fails to load on CentOS because of missing imports (GLIB_2_11, ...). I need C++ (including exceptions), so I can't just statically link against glibc, which I already tried.
Can I install the older gcc without removing the newer one? How do I go about the libs required by the older gcc?
I'm currently developing code in CentOS, but it's such a pain to use. I really want to move to an Ubuntu desktop.
g++-4.1 is available for Ubuntu; just run apt-get install g++-4.1 then run g++-4.1 instead of g++. However, simply using an older compiler may not fix all of your library issues.
Like Joachim Sauer said, your best bet is to do your development on Ubuntu then do the final compilation on CentOS.
Even though you're using C++, static linking should still be an option. (However, you're much better off compiling on CentOS and using dynamic linking.)
Edit: A virtual machine is the most straightforward way to build on CentOS, but if you want to avoid the memory and CPU overhead of running a VM and don't care about differences between Ubuntu's and CentOS's kernel, then you can create a subdirectory containing a CentOS or Fedora filesystem and chroot do that to do your builds. This blog posting has details.

Resources