gmp, mpc + mpfr: is not symbolic link - gcc

I build gcc 4.6.1 and when I run ldconfig it comes back with this result:
ldconfig: /usr/local/mpc/lib/libmpc.so.2 is not a symbolic link
ldconfig: /usr/local/gmp/lib/libgmp.so.3 is not a symbolic link
ldconfig: /usr/local/mpfr/lib/libmpfr.so.1 is not a symbolic link
Here is how I built gcc using the libraries:
tar jxf gmp-4.3.2.tar.bz2
cd gmp-4.3.2/
./configure --prefix=/usr/local/gmp
make
make install
cd ..
tar jxf mpfr-2.4.2.tar.bz2
cd mpfr-2.4.2/
./configure --prefix=/usr/local/mpfr --with-gmp=/usr/local/gmp
make
make install
cd ..
tar xzf mpc-0.8.1.tar.gz
cd mpc-0.8.1
./configure --prefix=/usr/local/mpc --with-mpfr=/usr/local/mpfr --with-gmp=/usr/local/gmp
make
make install
cd ..
tar jxf gcc-4.6.1.tar.bz2
cd gcc-4.6.1
./configure --prefix=/usr/local/gcc --enable-threads=posix --disable-checking -disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local/gmp --with-mpfr=/usr/local/mpfr/ --with-mpc=/usr/local/mpc/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc/lib:/usr/local/gmp/lib:/usr/local/mpfr/lib/
make
make install
cp gcc.4.6.1.conf /etc/ld.so.conf.d/gcc.4.6.1.conf
ldconfig
mv /usr/bin/gcc /usr/bin/gcc_old
mv /usr/bin/g++ /usr/bin/g++_old
ln -s -f /usr/local/gcc/bin/gcc /usr/bin/gcc
ln -s -f /usr/local/gcc/bin/g++ /usr/bin/g++
cp /usr/local/gcc/lib64/libstdc++.so.6.0.16 /usr/lib64/.
mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.bak
ln -s -f /usr/lib64/libstdc++.so.6.0.16 /usr/lib64/libstdc++.so.6
Please say I don't need to rebuild gcc! Is this symbolic link problem something that can really affect a program? Or will it not make any difference, it does pop up every now and again, for instance when I was yum install certain things as well. Thanks in advance.

I fixed this problem by installing gmp, mpc, and mpfr with the ./contrib/download_prerequisites command, which downloads the required files and sets up symbolic links during the install process.
My whole build was:
tar -xzvf gcc-4.6.2.tar.gz
cd gcc-4.6.2
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.6.2/configure --prefix=/opt/gcc-4.6.2
make
make install
ldconfig
mv /usr/bin/gcc /usr/bin/gcc_old
mv /usr/bin/g++ /usr/bin/g++_old
ln -s -f /usr/local/gcc/bin/gcc /usr/bin/gcc
ln -s -f /usr/local/gcc/bin/g++ /usr/bin/g++
cp /usr/local/gcc/lib64/libstdc++.so.6.0.16 /usr/lib64/.
mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.bak
ln -s -f /usr/lib64/libstdc++.so.6.0.16 /usr/lib64/libstdc++.so.6
export CC=gcc
export CXX=g++
I don't know how to fully link the CC and CXX variables to the new gcc and g++, but it works!

Related

Locally built GCC cross-compiler reports MB_LEN_MAX wrong with -D_FORTIFY_SOURCE=2

I am currently building a cross-compiler targeting the PowerPC architecture. It is capable of building Linux binaries that work and can execute on the target, however I hit a problem when I enable the compiler flag "-D_FORTIFY_SOURCE=2". I build a simple hello world application as so:
#include <limits.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
return 0;
}
I compile this using my cross-compiler and get the following error:
$ powerpc-linux-gnu-gcc -D_FORTIFY_SOURCE=2 -O2 hello.c
In file included from /opt/crossgcc/powerpc-linux-gnu/include/stdlib.h:958:0,
from hello.c:2:
/opt/crossgcc/powerpc-linux-gnu/include/bits/stdlib.h: In function 'wctomb':
/opt/crossgcc/powerpc-linux-gnu/include/bits/stdlib.h:90:3: error: #error "Assumed value of MB_LEN_MAX wrong"
# error "Assumed value of MB_LEN_MAX wrong"
^
I believe this is because I am not bootstrapping my GCC build correctly, but as far as I can see I am building it correctly. The script I am taking to build my compiler are as follows:
#! /bin/bash
set -e
INSTALL_PATH=$PWD/output
TARGET=powerpc-linux-gnu
LINUX_ARCH=powerpc
PARALLEL_MAKE=-j4
BINUTILS_VERSION=binutils-2.32
GCC_VERSION=gcc-8.3.0
LINUX_KERNEL_VERSION=linux-5.1.9
GLIBC_VERSION=glibc-2.29
export PATH=$INSTALL_PATH/bin:$PATH
cd $GCC_VERSION
./contrib/download_prerequisites
cd ..
mkdir -p build-binutils
cd build-binutils
../$BINUTILS_VERSION/configure --prefix=$INSTALL_PATH --target=$TARGET
make $PARALLEL_MAKE
make install
cd ..
cd $LINUX_KERNEL_VERSION
make ARCH=$LINUX_ARCH INSTALL_HDR_PATH=$INSTALL_PATH/$TARGET headers_install
cd ..
# Build GCC compiler
mkdir -p build-gcc
cd build-gcc
../$GCC_VERSION/configure \
--prefix=$INSTALL_PATH \
--target=$TARGET \
--disable-silent-rules \
--with-gnu-as --with-gnu-ld \
--enable-languages="c,c++" \
--enable-theads=posix \
--enable-c99 \
--enable-long-long \
--enable-lto \
--enable-libssp \
--enable-secureplt \
--disable-libmudflag \
--enable-secureplt \
--disable-nls \
--with-long-double-128
make $PARALLEL_MAKE all-gcc
make install-gcc
cd ..
mkdir -p build-glibc
cd build-glibc
../$GLIBC_VERSION/configure \
--prefix=$INSTALL_PATH/$TARGET \
--build=$(gcc -dumpmachine) \
--host=$TARGET \
--target=$TARGET \
--with-headers=$INSTALL_PATH/$TARGET/include \
libc_cv_forced_unwind=yes
make install-bootstrap-headers=yes install-headers
make $PARALLEL_MAKE csu/subdir_lib
install csu/crt1.o csu/crti.o csu/crtn.o $INSTALL_PATH/$TARGET/lib
$TARGET-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $INSTALL_PATH/$TARGET/lib/libc.so
touch $INSTALL_PATH/$TARGET/include/gnu/stubs.h
cd ..
cd build-gcc
make $PARALLEL_MAKE all-target-libgcc
make install-target-libgcc
cd ..
cd build-glibc
make $PARALLEL_MAKE
make install
cd ..
cd build-gcc
make $PARALLEL_MAKE all
make install
cd ..
Am I incorrectly bootstrapping my GCC? Should I be doing something differently to make GCC "aware" of my glibc headers?
By default the limits.h file is not properly configured, so you need to patch it.
To fix the problem you have to go inside GCC's source directory and type the command:
cd $GCC_VERSION
cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
`dirname $(${TARGET}-gcc -print-libgcc-file-name)`/include-fixed/limits.h
This adds a #include_next <limits.h> to the bottom which eventually picks up the right header.
Quickly adding to Anthony, to complete the debugging do not forget at the end of this step to use:
$LFS/tools/libexec/gcc/$LFS_TGT/10.2.0/install-tools/mkheaders

How to build a gcc cross compiler for arm64

On X86, I need to build a gcc cross compiler for arm64 with things as below:
binutils-2.26.1.tar.gz gcc-5.4.0.tar.gz glibc-2.23.tar.gz gmp-6.1.2.tar.bz2 mpc-1.1.0.tar.gz mpfr-4.0.1.tar.gz
I've put all of them into a directory named download.
After reading this link: http://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/, I wrote a bash script as below to build the gcc cross compiler:
#!/bin/bash
sudo rm -rf build sources /opt/aarch64-linux-gnu-5.4.0
mkdir build
cp -r download sources
cd sources
for f in *.tar*; do tar xf $f; done
cd gcc-5.4.0/
ln -s ../mpfr-4.0.1 mpfr
ln -s ../mpc-1.1.0 mpc
ln -s ../gmp-6.1.2 gmp
cd ../..
export PREFIX=/opt/aarch64-linux-gnu-5.4.0
#export PATH=$PREFIX/bin:$PATH
export SYSROOT=$PREFIX/sysroot
export TARGET=aarch64-linux-gnu
cd build
mkdir binutils && cd binutils
../../sources/binutils-2.26.1/configure --prefix=/$PREFIX --target=$TARGET
make -j32
make install
cd ..
cd /home/me/projet/kernel/linux-4.1
make ARCH=arm64 INSTALL_HDR_PATH=$PREFIX/aarch64-linux-gnu/include headers_install
cd -
mkdir gcc && cd gcc
../../sources/gcc-5.4.0/configure --prefix=$PREFIX --target=$TARGET --enable-languages=c,c++ --without-headers
make -j32 all-gcc
make install-gcc
cd ..
mkdir -p glibc && cd glibc
../../sources/glibc-2.23/configure --prefix= --build=$MACHTYPE --host=$TARGET --target=$TARGET --with-headers=$PREFIX/aarch64-linux-gnu/include libc_cv_forced_unwind=yes
make prefix=$PREFIX/aarch64-linux-gnu install-bootstrap-headers=yes install-headers
make -j32 csu/subdir_lib
install csu/crt1.o csu/crti.o csu/crtn.o $PREFIX/aarch64-linux-gnu/lib
/opt/aarch64-linux-gnu-5.4.0/bin/aarch64-linux-gnu-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $PREFIX/aarch64-linux-gnu/lib/libc.so
touch $PREFIX/aarch64-linux-gnu/include/gnu/stubs.h
cd ..
cd gcc
make -j32 all-target-libgcc
make install-target-libgcc
cd ..
cd glibc
make -j32
make prefix=$PREFIX/aarch64-linux-gnu install
cd ..
cd gcc
make -j32
make install
cd ..
However, when I executed this bash script, I got two errors:
cc1: error: no include path in which to search for stdc-predef.h
In file included from ../../../../sources/gcc-5.4.0/libgcc/gthr.h:148:0,
from ../../../../sources/gcc-5.4.0/libgcc/libgcov-interface.c:27:
./gthr-default.h:35:21: fatal error: pthread.h: No such file or directory

FGSL configuration with local install of GSL

I would like to use library fgsl, that depends on gsl. I have problem indicating where gsl is installed while configuring fgsl. I want to use the static version of these libraries. I can not use gsl library from Linux packages, these versions are not recent enough.
First I download, configure, compile and install gsl locally, i.e. using the --prefix option. (Instructions are presented below)
Then I download fgsl, configure it. This last operation fails because I do not succeed indicating where is gsl. I have tried to use gsl_LIBS unsuccessfully.
wget http://ftp.igh.cnrs.fr/pub/gnu/gsl/gsl-2.3.tar.gz -O gsl.tar.gz
mkdir -p gsl_build && cd gsl_build
tar -xzf ../gsl.tar.gz --strip 1
autoreconf -fi
./configure CFLAGS="-Wall" --prefix `pwd`/../gsl
make
make install
cd ..
rm -rf gsl_build
Here are the commands I run to install fgsl
wget https://github.com/reinh-bader/fgsl/archive/v1.2.0.tar.gz -O fgsl.tar.gz
mkdir -p fgsl_build
cd fgsl_build
tar -xzf ../fgsl.tar.gz --strip 1
autoreconf -fi
export gsl_LIBS=`pwd`/../gsl/lib
./configure CFLAGS="-Wall" FCFLAGS="-Wall" --prefix `pwd`/../fgsl --libdir=`pwd`/../gsl/lib --includedir=`pwd`/../gsl/include
make
make check
make install
cd ..
rm -rf fgsl_build
I try to do this for the open source project AcousticBEM. Here is the log presenting the problem.
Well, here are my updated scripts to install gsl and fgsl locally. I have used PKG_CONFIG_PATH to tell fgsl where gsl is installed. I end up with a directory named gsl containing gsl libraries and fgsl libraries.
First a shell script to install gsl
export gsl_INSTALL_DIR=`pwd`/gsl
[ -f ./gsl.tar.gz ] && echo "No need to download gsl" || wget http://ftp.igh.cnrs.fr/pub/gnu/gsl/gsl-2.3.tar.gz -O gsl.tar.gz
mkdir -p gsl_build
cd gsl_build
tar -xzf ../gsl.tar.gz --strip 1
autoreconf -fi
./configure CFLAGS="-Wall" --prefix=${gsl_INSTALL_DIR}
make
make install
cd ..
rm -rf gsl_build
Second, a script to install fgsl locally using the newly install gsl
export PKG_CONFIG_PATH=`pwd`/gsl/lib/pkgconfig
export gsl_LIBS=`pwd`/gsl
[ -f ./fgsl.tar.gz ] && echo "No need to download fgsl" || wget https://github.com/reinh-bader/fgsl/archive/v1.2.0.tar.gz -O fgsl.tar.gz
mkdir -p fgsl_build
cd fgsl_build
tar -xzf ../fgsl.tar.gz --strip 1
autoreconf -fi
./configure CFLAGS="-Wall" FCFLAGS="-Wall" --prefix=${gsl_LIBS}
make
make check
make install
cd ..
rm -rf fgsl_build

build static sox with lame and flac support for AWS lambda

I'm trying to use sox in a AWS lambda function for conversion of FLAC file to MP3, but I cannot seem to build a version of sox with FLAC support.
I have found this great solution that I have been using but it doesn't support FLAC.
I've searched the net for alternatives but nothing seems to work. I've also read that at some stage FLAC support went missing but should have been fixed.
I'm still looking for answers, but any help is appreciated.
You need to add the libvorbis and flac libraries to your static build and flag the sox build to include them. I have made changes to the script from your example questions to show you how this done.
sudo yum update
sudo yum install gcc44 gcc-c++ libgcc44 cmake –y
# now grab sox and its dependencies
mkdir -p deps
mkdir -p deps/unpacked
mkdir -p deps/built
mkdir -p deps/built/libmad
mkdir -p deps/built/sox
mkdir -p deps/built/lame
mkdir -p deps/built/libvorbis
mkdir -p deps/built/flac
wget -O deps/sox-14.4.2.tar.bz2 "http://downloads.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fsox%2Ffiles%2Fsox%2F14.4.2%2F&ts=1416316415&use_mirror=heanet"
wget -O deps/libmad-0.15.1b.tar.gz "http://downloads.sourceforge.net/project/mad/libmad/0.15.1b/libmad-0.15.1b.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmad%2Ffiles%2Flibmad%2F0.15.1b%2F&ts=1416316482&use_mirror=heanet"
wget -O deps/lame-3.99.5.tar.gz "http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Flame%2Ffiles%2Flame%2F3.99%2F&ts=1416316457&use_mirror=kent"
wget -O deps/libvorbis-1.3.5.tar.xz "http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.xz"
wget -O deps/flac-1.3.2.tar.xz "https://superb-dca2.dl.sourceforge.net/project/flac/flac-src/flac-1.3.2.tar.xz"
# unpack the dependencie
pushd deps/unpacked
tar xvfp ../sox-14.4.2.tar.bz2
tar xvfp ../libmad-0.15.1b.tar.gz
tar xvfp ../lame-3.99.5.tar.gz
tar xvfp ../libvorbis-1.3.5.tar.xz
tar xvfp ../flac-1.3.2.tar.xz
popd
# build libmad, statically
pushd deps/unpacked/libmad-0.15.1b
./configure --disable-shared --enable-static --prefix=$(realpath ../../built/libmad)
# Patch makefile to remove -fforce-mem
sed s/-fforce-mem//g < Makefile > Makefile.patched
cp Makefile.patched Makefile
make
make install
popd
# build lame, statically
pushd deps/unpacked/lame-3.99.5
./configure --disable-shared --enable-static --prefix=$(realpath ../../built/lame)
make
make install
popd
# build libvorbis, statically
pushd deps/unpacked/libvorbis-1.3.5
./configure --disable-shared --enable-static --prefix=$(realpath ../../built/libvorbis)
make
make install
popd
# build flac, statically
pushd deps/unpacked/flac-1.3.2
./configure --disable-shared --enable-static --prefix=$(realpath ../../built/flac)
make
make install
popd
# build sox, statically
pushd deps/unpacked/sox-14.4.2
./configure --disable-shared --enable-static --prefix=$(realpath ../../built/sox) \
LDFLAGS="-L$(realpath ../../built/libmad/lib) -L$(realpath ../../built/lame/lib) -L$(realpath ../../built/libvorbis/lib) -L$(realpath ../../built/flac/lib)" \
CPPFLAGS="-I$(realpath ../../built/libmad/include) -I$(realpath ../../built/lame/include) -I$(realpath ../../built/libvorbis/include) -I$(realpath ../../built/flac/include)" \
--with-mad --with-lame --with-libvorbis --with-flac --without-oggvorbis --without-oss --without-sndfile --without-gomp
make -s
make install
popd
cp deps/built/sox/bin/sox .
rm -rf deps/built
rm -rf deps/unpacked

Issue linking gcc-4.7 Mac OSX 10.6

So I downloaded gcc using homebrew so that I could update gcc and g++ to 4.7.
So then I:
$ mkdir ~/bin
created ~/.bashrc with contents:
'export PATH=$HOME/bin:$PATH'
created ~/.bash_profile with contents:
'. $HOME/.bashrc'
and then:
$ ln -s /usr/local/bin/g++-4.7 ~/bin/g++
so now I run g++ -v and it's 4.7, YAY!
Now I go to update gcc and do:
$ ln -s /usr/local/bin/gcc-4.7 ~/bin/gcc
I get no errors but then when I run gcc -v i get:
gcc-4.7: error trying to exec '/usr/local/bin/i686-apple-darwin10-gcc-4.2.1': execvp: No such file or directory
So it seems to be looking for 4.2 for some reason? If I cd to ~/bin/gcc and do ./gcc -v it works fine. Also echo $PATH has the correct ~/bin path. I'm not sure why g++ worked and gcc didnt.
I had the same problem.
This is because bash has hashed the gcc in other folder.
run: hash gcc
Then everything should go smooth.

Resources