How can I obtain a newer GCC? I don't have root, and can't compile it (memory error) - linux

I have a shared account on a machine that is running an older version of GCC. I do not have root. When I try to compile GCC, my build process gets killed due to memory usage from the following command:
build/genattrtab ../../../work/gcc-6.1.0/gcc/common.md ../../../work/gcc-6.1.0/gcc/config/i386/i386.md insn-conditions.md \
-Atmp-attrtab.c -Dtmp-dfatab.c -Ltmp-latencytab.c
I'd really like to be able to compile some software on this machine that requires a newer GCC. Any suggestions are appreciated.

You can manually unpack one of the GCC packages for any major distribution, try to use the package that closely matches your distribution. These installable packages are just tar files with some meta data and install script. You can unpack them and extract binaries that you'll need. Just keep in mind that you might need to more than just gcc package. Some distributions chop their devtools into tons of small packages ( gcc, g++, binutils, gdb)
Another good source is to use pre-build gcc toolchain used by embedded vendors, sometimes these vendors include host version of gcc together with cross-compiler. For example Android NDK is one of such distributions.
Finally, you can compile GCC on another machine that is not so restrictive and copy the resulting binaries to your restrictive machine. As in case of the first approach of unpacking installable package, try to find machine that resembles your restrictive machine as close as possible. You can use tools like vagrant and docker to set-up close replica of your target machine. Vagrant and docker have a lot of pre-built templates that you can use as a jump start to create the machine you need.

Related

Basic set of libraries in chroot (fedora linux)

I'm running an old version of my linux distro (fedora, but this is not very relevant) and for reasons which are completely irrelevant I'm not in a position to update it. However I do need a newer version of gcc and some other libraries than those supplied by my old distro.
I could compile a newer gcc and all the other libraries of course but I thought the simplest way would be to install a minimal set of packages from the latest distro version to a directory and then just chroot there. This way I'd take advantage of the binary packages present in the newest distro and all the infrastructure around it (like dependency installation, etc.) and I wouldn't need to compile everything from source.
My question is this: if I only would like to be able to compile with the most recent gcc and run those programs, what is the minimal set of packages I need? Since we are talking about fedora, what is the minimal set of rpms (beyond glibc and gcc)? Note that I don't need any X environment, networking, or anything like that, only the most basic terminal tools.
The minimal set varies depending on your user needs and what you're linking with. What I do when making a chroot environment is have a look at the distro I want to chroot and see if they have a base rpm/deb package that kickstarts everything. Then I install that in the chroot. From there I add libraries and applications as needed.
For an example where I create a chroot for RHEL on Arch see http://www.zenskg.net/wordpress/?p=267

how to compile apache,mysql and php in linux

I have never used Linux OS. Want to know how we can start compiling Apache,Mysql and php in Linux and is it necessary to configure it.
I tried doing it by using cd/user/scr/httpd_2.0.09
Do we need to downloads the set up from google
Do yourself a favour and don't try to compile your own webserver etc. ;)
Aside from the fact that it's a lot of work to set up the tools for compiling, resolve dependencies, and debug possible errors, you will have to do the same procedure with every tiny update – instead of simply getting a new version via your package manager.
If you use a common distribution, install the packages required for the so-called LAMP stack, and configure them properly. That will be hard enough for starters.
If you're using Ubuntu, have a look here: https://help.ubuntu.com/community/ApacheMySQLPHP
Actually installing binaries from repositories is less painful than compiling, but if you really want so, you may install Gentoo or other source-based distributive. I've simply described compilation of MySQL 5.5 in my blog.
To compile packages on Debian based systems you need to install build-essential and cmake package (and maybe some other *-dev packages, which appears to be missing during source configure).
For example to compile MySQL 5.5 it is enough to run:
cmake . #yep, with dot. Will prepare your source according to your system
make
make install #will install compiled binaries to system

How to compile software into a re-installable form?

I am working through my 7th recompile of the same software. There are no pre-built packages available, and it's a long compile time. Is there a way to take what I compile and package it up so that I don't have to continually build it right from source?
EDIT: CentOS 6 for the OS if that matters.
You should have a look at CDE. From its website :
CDE (formerly known as CDEpack) automatically packages up the Code, Data, and Environment required to deploy and run your Linux programs on other machines without any installation or configuration. CDE is the easiest way to completely eliminate dependency hell.
So it will compile your program and include all the dependencies in the resulting package as well. The resulting package should be able to run on any modern x86 Linux distribution, so you won't have to continually build it right from source.
checkinstall, which is based on installwatch, is able to create various packages including .deb (Debian, Ubuntu, ...), .rpm (Red Hat, Fedora, SuSE, ...) and .tgz (Slackware) suitable for your distribution's package manager.

Cross-compiler for Linux on Mac OS X?

I've been reading lots of documents on the internet about creating a cross compiler for linux on mac os x but can't seam to get any to work.
It seams as if no one can help me with the question: Getting GMP to work with GCC 4.5.2
Is there any easy'er way to create a cross compiler?
You need to:
install the xcode base build tools
install the optional xcode command line tools
install homebrew
install the homebrew build tools
4.1 brew install crosstool-ng mpfr gmp grep
4.2 brew tap homebrew/dupes
create a case sensitive volume using "disk utility"
use this volume to build the tool chain itself
6.1 generate a base configuration (for me this is an arm cortex a8)
6.1.1 ct-ng arm-cortex_a8-linux-gnueabi
6.2 use menuconfig (ct-ng menuconfig) to tweak the configuration
6.2.1. disable fortran and java (c compiler)
6.2.2. turn off static linking (c compiler)
6.2.3. change the paths to be on the volume you created above (paths and misc options)
6.2.4. remove dmalloc (debug facilities)
6.3 invoke the build:
6.3.1 ulimit -n 1024
6.3.2 ct-ng build
with much thanks to the crosstools-ng list.
In order to build binaries for architectures different that your build host, you need far more than just a cross-compiler - you need a full-blown toolchain, which can be a real pain to create, as you probably discovered.
A couple of approaches:
Use a proper Linux distribution in a virtual machine, such as VirtualBox. If you only want to build binaries for Linux/i386 on an MacOSX/x86_64 host, this is - in my opinion - the easiest, safest and most clean solution. It is not a cross-compiler, of course, but it works and it has the added advantage that you can actually test your executables.
Use a script such crosstool-NG (a descendant of the original crosstool) to automatically build the toolchain - definitely easier than building it on your own, although you may have to compromise for slightly older compiler versions.

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