Why does Ubuntu install ARM64 compilers with a version suffix that breaks autoconf? - linux

I just installed the ARM64 cross-complier (aarch64-linux-gnu) on x86_64 Ubuntu 16.04 and all of the binaries have "-4.8" (like aarch64-linux-gnu-gcc-4.8). When I try to configure with --host=aarch64-linux-gnu, it fails to find aarch64-linux-gnu-gcc and falls back to the native gcc.
What did I miss? Is there an additional package that needs installation other than gcc-4.8-aarch64-linux-gnu? Or is there another mystery parameter to autogen.sh/configure that I don't know about?
Thanks.

Related

Toolchain to crosscompile Applications for BBB

My native machine is ubuntu based 14.04 LTS x86_64 system, I want to cross-compile applications and QT programs for Beaglebone black, which is an armv7 based system running on Debian 2015 distribution.
Which toolchain I should install on my native system, to get this done?
Here is a very usefull link how to set up the crosscompiler, uboot, kernel and the filesystem for a beaglebone black.
If you only want to crosscompiler, then just follow the few code lines in the Crosscompiler chapter
https://eewiki.net/display/linuxonarm/BeagleBone+Black
To cross-compile applications you need to use the ' arm-linux-gnueabihf ' compiler in the Ubuntu. Ubuntu 14.04 LTS was released with gcc-4.8.2. It is really important that the version of this GCC compiler matches the version deployed on the beaglebone black image. The reason for this is that different compilers have different libc versions, and version mismatching causes linker errors that are very tricky to solve.
You can try running,
gcc --version
on both your native Ubuntu system and the Beaglebone Black and see if the gcc version matches. If yes, you are good to go. Otherwise, install the appropriate toolchains.

Optimal way to install clang locally when GCC is outdated

I need to use tools that depend on clang on a Unix machine I remote onto at work. Anything I install is locally installed onto ~/local. I do not have root permissions.
/usr is pretty outdated, with gcc being at version 4.4.7. clang requires gcc 4.7+
I read on linux from scratch that a gcc 6.1 installation requires 8.4 gb. This is not something I can do, because that's huge.
Can someone advise me on the best workaround to install up to date clang on my ~/local?
Please and thanks.
Edit:
Courtesy of Nishant, here is the short answer:
Set up a personal machine running the same linux distro and cross compile using gcc to your specific architecture. For me, I will run a Redhat 6.5 VM and compile using gcc an arm x64 binary. Thanks Nishant!
You can get pre-build binaries for Unix system from LLVM's release website: http://llvm.org/releases/
You can then put the binaries in any local folder you want and source it using the PATH variable, which can be done by modifying your ~/.bashrc file by appending:
export PATH=$PATH:<clang-binary-directory>
Now you will able to use clang from the command line terminal as if it was installed.
If you want to build from source only, you can get older source code of clang which will use gcc 4.4.7 and build it and then use clang to build clang. Or get the latest clang binary and use it to build latest clang.

Compiling For 64bit Architecture in Ubuntu 32bit

I'm looking for tutorial how to compile project for 64bit architecture in ubuntu 32 bit architecture. I have to put this project on shared hosting machine which is x86_64 architecture. I can't compile this project on remote machine because I didn't have permissions to install some dependencies for this project.
When I try to put compiled project from my computer (ubuntu 32 bit) the execution fails because of floating point exceptions. The same scenario with simple hello_world application.
I'm total beginner with gcc, ld and I was always using compiled packages but now I have to compile for target machine different than mine.
For now I figured out that I need to install g++-multilib and add to CCFLAGS -m64 to the gcc.
Now I have errors like this:
/usr/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc
Is there any way to compile dependency libraries inside aplication so I didn't have to resolve dependency libraries on the remote machine.
You need to install a 64-bit library pack.
apt-get install ibc6-dev-amd64
or something close to that (I used to have an Ubuntu machine at work, but I'm using Fedora at home, so can't even attempt to try what I'm suggesting - I know the principle is correct, but the exact detail is a bit vague)

Compiling libcurl x86 on Linux x64

I've cross-compiled the bulk of my 32-bit code on my x64 Ubuntu install, but I can't work out how to do the same trick with libcurl.
I've tried many permutations of --host and/or --build i486, x86, etc. but none have helped. I've also tried editing the makefiles to include gcc's -m32 flag manually, but it never shows up when I run them.
What should I be doing?
After you download and extract the libcurl source package, as a root user, run this command for setting up the build environment.
configure --host=i686-pc-linux-gnu CFLAGS=-m32 CC=/usr/bin/gcc
followed by
make
you can find the libs under ./lib/.libs/libcurl.so from where you ran the make command.
if you dont find /usr/bin/gcc, you will have to install gcc for 32-bit cross compilation env in a 64-bit machine.
It would help if you gave us an error message. I've had issues on Ubuntu x64 systems compiling 32-bit code with 'ld' errors.. I solved it by adding LDEMULATION=elf_i386 to my environment.

Compiling for amd64 under i386 Debian

Cheers,
I want to avoid problems with compiling my code on amd64, yet I don't have a 64-bit CPU available and have no hopes of getting upgrade to my machine any time soon. I have no dreams of testing the code (although that should theoretically be possible using qemu-system) but I'd like to at least compile the code using gcc -m64.
Basic idea works:
CFLAGS=-m64 CXXFLAGS=-m64 ./configure --host x86_64-debian-linux
However, the code depends on some libraries which I typically install from Debian packages, such as libsdl1.2-dev, libgmp3-dev and such. Obviously, getting 64-bit versions of packages installed alongside of 32-bit versions is not a one-liner.
What would be your practices for installing the 64-bit packages? Where would you put them, how would you get them there and how would you use them?
To repeat, I don't have 64-bit CPU and cannot afford getting a new machine.
I have already set up amd64-libs-dev to give some basic push to gcc's -m64.
Attempted so far:
Setting up a 64-bit chroot jail with debootstrap in order to simplify installation of 64-bit development packages for libraries. Failed since finishing the setup (and installing anything afterwards!) requires 64-bit CPU.
Installing gcc-multilib and g++-multilib. This appears to do nothing beside depending on libc6-dev-amd64 which I already installed through amd64-libs-dev.
If you're using debian, before you can use gcc -m64, you need to install gcc-multilib and g++-multilib. This will also install all files needed to link and create a 64bit binary.
You don't have to have a 64bit capable CPU for this either.
Then you can call GCC as follows:
$ gcc -m64 source.c -o source
As for external libraries, debian takes care of that if you have multilib installed. I have a 32bit machine that compiles 64bit code for another machine and links a handful of libraries (libpng, libz for example). Works great and the executable run (debian to debian).
You want to look into the dchroot package to set up a simple chroot(8) environment -- that way you can compile real amd64 binaries in a real 64-bit setting with proper libraries and dependencies. This surely works the other way (i.e. I am using i386 chroots on amd64 hosts) but I don't see why it shouldn't work the other way if your cpu supports amd64.
Edit: Now that you stress that you do not have a amd64-capable cpu, it gets a little trickier. "In theory" you could just rebuild gcc from source as a cross-compiler. In practice, that may be too much work. Maybe you can just get another headless box for a few dollars and install amd64 on that?
check out this fine article that describes how to easily create a 32bit chroot, where you can install all the 32bit tools (gcc and libs)
Doesn't Debian distinguish between lib32 and lib64 directories? In that case, you can just grab the packages and force them to install, regardless of architecture.
If that does not work (or would hose your system!) I would set up a chroot environment and apt-get the 64-bit libraries into there.
Check out pbuilder, It can create build environments for many architectures, some instructions here
Try cross compiling SDL, gmp and other libraries yourself. Or manually extract the files you need from the Debain packages.

Resources