LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-07-2016, 03:25 AM   #1
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 70
multiple versions of gcc...


I run CentOS 6.8 which has gcc 4.4. I want C++14 functionality so I installed another version of gcc2 to /usr/local/gcc2.

So I use /usr/local/bin/g++ which is symlinked from /usr/local/gcc2/bin/g++.

I tried using std::move which I understood was C++11. However, I get this.
Code:
rgonzale@darkstar:~1039 g++ -std=c++11 move.cpp 
rgonzale@darkstar:~1040 ./a.out
./a.out: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by ./a.out)
I see that g++ is grabbing libstdc++ from /usr/lib64.
Code:
rgonzale@darkstar:~1050 strings /usr/local/gcc2/lib64/libstdc++.so | grep GLIBC
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBC_2.3
GLIBC_2.2.5
GLIBC_2.3.2
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH
rgonzale@darkstar:~1051 strings /usr/lib64/libstdc++.so | grep GLIBC
strings: '/usr/lib64/libstdc++.so': No such file
rgonzale@darkstar:~1052 strings /usr/lib64/libstdc++.so.6 | grep GLIBC
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.4
GLIBC_2.3.2
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH
How can I tell g++ to grab libstdc++ from /usr/local/gcc2/lib64?

-Tristan
 
Old 07-07-2016, 04:52 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
The right setup for a manual build is a different name for the "extra g++/gcc" :

cd /usr/local/bin/
# rm g++
# ln -s /usr/local/gcc2/bin/g++ g++49 ( or whatever version you have built.)

Using, examples : 1) export CC=gcc[2] CXX=g++[2] && [other command]
2) make CXX=g++[2]
3) CXX=g++[2] cmake

4) Starting an application requiring /usr/local/gcc2/lib64/libstdc++.so.6 :
export LD_LIBRARY_PATH=/usr/local/gcc2/lib64:$LD_LIBRARY_PATH && [other command]
.... then /usr/local/gcc2/lib64 comes first in the LD_LIBRARY_PATH .

--------------
Another way having extra compilers in CentOS 6.8 :
https://www.softwarecollections.org/.../devtoolset-4/

# yum install centos-release-scl

# yum install devtoolset-2-gcc-c++ (provides gcc / g++ 4.8)
# yum install devtoolset-3-gcc-c++ (provides gcc / g++ 4.9)
# yum install devtoolset-4-gcc-c++ (provides gcc / g++ 5.2)
.... Unfortunately they all use the stock /usr/lib64/libstdc++.so.6


-

Last edited by knudfl; 07-07-2016 at 10:34 AM.
 
Old 07-07-2016, 01:52 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
I would discourage you from having multiple versions of gcc, nor (especially!) glibc, if you can possibly avoid it.
 
Old 07-07-2016, 02:37 PM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Re #3.
Quote:
I would discourage you from having multiple versions of gcc
Why ? Slackware, Fedora, CentOS, Debian, Ubuntu, Suse have 1 .. 4 extra versions of gcc/g++ available.
Examples ...
CentOS 5 : /usr/bin/{ gcc(-4.1.2), gcc34, gcc44 gcc-4.7, gcc-4.8 }
Debian Wheezy : /usr/bin/{ gcc(-4.7.2), gcc-4.4, gcc-4.6 }
Ubuntu 14.04 : /usr/bin/{ gcc(-4.8.2), gcc-4.4, gcc-4.6, gcc-4.7 }
SLE12 (Suse) : /usr/bin/{ gcc-3.3, gcc-4.8, gcc-4.9, gcc-5, gcc-6 }.


-

Last edited by knudfl; 07-07-2016 at 02:43 PM.
 
Old 07-08-2016, 07:39 AM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Available? Yes. Installed simultaneously? Probably not.

Nevertheless: the really important one is glibc, which is used by most Linux commands. It's very important that this library be in good working order.
 
Old 07-08-2016, 10:36 AM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Re #5.

Yes, simultaneously. As you can see, they all have unique file names.
Or, for the "devtoolset-[x]-gcc-c++" examples :
Well hidden, and enabled with 'scl enable devtoolset-[x] bash'

Or the manually built gcc´s, example :
../gcc-5.2.0/configure --prefix=/usr/local/gcc52 --program-suffix=52 -- ...
I.e. you get/usr/local/gcc52/bin/{ gcc52, g++52 }.

No conflicts.
 
Old 07-08-2016, 12:14 PM   #7
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
The newer libstdc++.so.6 might be able to provide the functions of the older. Perhaps. (Remember, it is C++)

Last edited by NevemTeve; 07-08-2016 at 12:16 PM.
 
Old 07-08-2016, 12:21 PM   #8
a4z
Senior Member
 
Registered: Feb 2009
Posts: 1,727

Rep: Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742
on CentOS/RHEL use softare collections

https://www.softwarecollections.org/.../devtoolset-3/

or, this is how I builded int this case gcc 5.3

Code:
unset LIBRARY_PATH

GCCVERSION=5.3.0

../configure          \
    --prefix=$HOME/local/opt/gcc-$GCCVERSION          \
    --libdir=$HOME/local/opt/gcc-$GCCVERSION/lib      \
    --enable-lto                \
    --disable-nls               \
    --enable-languages=c,c++

make -j10 && make install


and this is how I active the environment (by sourcing this file for a terminal)


Code:
GCCVERSION=5.3.0

export GCCDIR=$HOME/local/opt/gcc-$GCCVERSION


export LIBDIR=$GCCDIR/lib:/usr/local/lib
export PATH=$GCCDIR/bin:$CMAKEDIR/bin:$HOME/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
export LD_LIBRARY_PATH=$LIBDIR
export C_INCLUDE_PATH=$GCCDIR/include
export CXX_INCLUDE_PATH=$GCCDIR/include/c++/$GCCVERSION

export CC=$GCCDIR/bin/i686-pc-linux-gnu-gcc
export CXX=$GCCDIR/bin/i686-pc-linux-gnu-g++
that's from a RHEL 6.8 workstation,
 
  


Reply

Tags
devtoolset



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple gcc versions? Zeno McDohl Linux - Server 17 01-12-2009 06:40 AM
Having multiple versions of GCC Rostfrei Programming 4 11-21-2007 01:10 AM
Multiple versions of GCC Denisius Slackware 11 11-15-2007 07:39 AM
multiple versions of gcc Avatar33 Linux - General 3 02-22-2005 02:06 PM
multiple gcc versions and selectability tincat2 Linux - Software 1 06-08-2003 02:38 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration