Upgrade gcc4.2 to gcc4.8

Hi,

I need to upgrade gcc to compile a dynamic library in C++. I've already installed gcc48 but typing gcc --v it says I'm still using gcc42, so I've solved typing gcc48 directly but:
Code:
g incompatible /usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd9.1/4.8.1/libgcc.a when searching for -lgcc
/usr/local/bin/ld: skipping incompatible //usr/lib/libgcc.a when searching for -lgcc
/usr/local/bin/ld: cannot find -lgcc
/usr/local/bin/ld: skipping incompatible /usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd9.1/4.8.1/../../../libgcc_s.so when searching for -lgcc_s
/usr/local/bin/ld: skipping incompatible //usr/lib/libgcc_s.so when searching for -lgcc_s
/usr/local/bin/ld: cannot find -lgcc_s
/usr/local/bin/ld: skipping incompatible //usr/lib/libc.so when searching for -lc
/usr/local/bin/ld: skipping incompatible //usr/lib/libc.a when searching for -lc
/usr/local/bin/ld: cannot find -lc
/usr/local/bin/ld: skipping incompatible /usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd9.1/4.8.1/libgcc.a when searching for -lgcc
/usr/local/bin/ld: skipping incompatible //usr/lib/libgcc.a when searching for -lgcc
/usr/local/bin/ld: cannot find -lgcc
/usr/local/bin/ld: skipping incompatible /usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd9.1/4.8.1/../../../libgcc_s.so when searching for -lgcc_s
/usr/local/bin/ld: skipping incompatible //usr/lib/libgcc_s.so when searching for -lgcc_s
/usr/local/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status

How do I fix this? :\
 
I'll share my experience with gcc48.

I'm not using it to compile ports or kernel/world because it is not officially supported and I'm not looking for trouble. However, at my company we develop cross-platform applications for Windows/Linux/Unix and we use FreeBSD 9.1 as our Unix testing platform.

These applications/libraries are all contain C++11 features, so we need to use the latest compilers which support C++11. We use GCC 4.8.

What I changed on my system:
  1. Installed GCC 4.8 from ports.
  2. Installed the latest devel/gdb from ports (the one in the base does not support new language features)
  3. Added the following lines to /etc/profile:
    Code:
    export LD_LIBRARY_PATH=/usr/local/lib/gcc48:${LD_LIBRARY_PATH}
    export CC=/usr/local/bin/gcc48
    export CXX=/usr/local/bin/g++48
    alias make="gmake"
    alias gdb="/usr/local/bin/gdb76"
    alias g++="g++48"
  4. Added the following line to ~/.bashrc (if you using other shell than bash, then you need to do it as described for your shell):
    Code:
    source /etc/profile
  5. Log off and log in.
Now when I log in as my user, gcc and g++ are aliases of gcc48 and g++48 respectively. New C++11 libraries from /usr/local/lib/gcc48 are being used by linker. We use gmake instead of make, that's why I have an alias for make.

I also managed to install Eclipse Juno and the CDT plugin on FreeBSD which is also very helpful.
 
You have to adjust /etc/libmap.conf to get the C++ stuff to link properly. The libgcc.so library that comes with the base system is only for code that is compiled with the built-in gcc/g++ version 4.2.1.
 
kpa said:
You have to adjust /etc/libmap.conf to get the C++ stuff to link properly. The libgcc.so library that comes with the base system is only for code that is compiled with the built-in gcc/g++ version 4.2.1.

I haven't applied any changes to this file and it still links correctly on my machine. Maybe because of the below line?
Code:
export LD_LIBRARY_PATH=/usr/local/lib/gcc48:${LD_LIBRARY_PATH}
 
Back
Top