Using newer gcc in /opt/netapps: Difference between revisions

From LWP-Wiki
Jump to navigation Jump to search
(Fit script to version 5.2)
(Snippet failed for 5.2 Now it works)
Line 1: Line 1:
[[Category:software-faq]]
[[Category:software-faq]]
Gcc-4.9.1 is in /opt/netapps/gnu/gcc. In order for you to use it, this may have to be appended to your .profile, .bash_profile or whatever applies.
 
Gcc-5.2 is in /opt/netapps/gnu/gcc/5.2. In order for you to use it, this may have to be appended to your .profile, .bash_profile or whatever applies.
 


  # This is a bash snippet, to be sourced from .profile
  # This is a bash snippet, to be sourced from .profile
   
   
  GCCBASE="/opt/netapps/gnu/gcc/5.2"
  GCCBASE="/opt/netapps/gnu/gcc/5.2"
LIBDIRS="$(find ${GCCBASE} -iname \*\.so\.\* -exec dirname {} \;|sort |uniq|grep -v 32$|tr '\n' ':')"
   
   
  # If you want the newer tools by default, put them at the beginning of $PATH
  # If you want the newer tools by default, put them at the beginning of $PATH
Line 13: Line 17:
   
   
  # For good measure: default compiler flags for the C++ course
  # For good measure: default compiler flags for the C++ course
  export CXXFLAGS="${CXXFLAGS} -Wall -std=c++11"
  export CXXFLAGS="${CXXFLAGS} -Wall -std=c++14"
   
   
  # This is for during compile: prefer newer headers
  # This is for during compile: prefer newer headers
Line 19: Line 23:
   
   
  # This is for linking during build: prefer newer libraries
  # This is for linking during build: prefer newer libraries
  export LD_LIBRARY_PATH="${GCCBASE}/lib/../lib64:${LD_LIBRARY_PATH}"
# (with 5.2, this seems to affect run-time)
  export LD_LIBRARY_PATH="${LIBDIRS}:${LD_LIBRARY_PATH}"
# With 5.2, this affects build time
export LIBRARY_PATH="${LIBDIRS}:${LIBRARY_PATH}"
   
   
  # This is for runtime linking: prefer older libraries
  # This is for runtime linking: prefer older libraries
  export LD_RUN_PATH="${LD_RUNPATH}:${GCCBASE}/lib/../lib64"
  #export LD_RUN_PATH="${LD_RUNPATH}:${GCCBASE}/lib/../lib64"
   
   
  # Man should also find the newer manpages
  # Man should also find the newer manpages
  export MANPATH="${MANPATH}:${GCCBASE}/share/man"
  export MANPATH="${MANPATH}:${GCCBASE}/share/man"


Please note: /opt is *NOT* in ld.so.conf, and should not be
Please note: /opt is *NOT* in ld.so.conf, and should not be

Revision as of 08:12, 18 August 2015


Gcc-5.2 is in /opt/netapps/gnu/gcc/5.2. In order for you to use it, this may have to be appended to your .profile, .bash_profile or whatever applies.


# This is a bash snippet, to be sourced from .profile

GCCBASE="/opt/netapps/gnu/gcc/5.2"

LIBDIRS="$(find ${GCCBASE} -iname \*\.so\.\* -exec dirname {} \;|sort |uniq|grep -v 32$|tr '\n' ':')"

# If you want the newer tools by default, put them at the beginning of $PATH
export PATH="${PATH}:${GCCBASE}/bin"

# Have Make pick the newer compiler
export CXX="${GCCBASE}/bin/g++"

# For good measure: default compiler flags for the C++ course
export CXXFLAGS="${CXXFLAGS} -Wall -std=c++14"

# This is for during compile: prefer newer headers
CPLUS_INCLUDE_PATH="${GCCBASE}/include:${CPLUS_INCLUDE_PATH}"

# This is for linking during build: prefer newer libraries
# (with 5.2, this seems to affect run-time)
export LD_LIBRARY_PATH="${LIBDIRS}:${LD_LIBRARY_PATH}"

# With 5.2, this affects build time
export LIBRARY_PATH="${LIBDIRS}:${LIBRARY_PATH}"

# This is for runtime linking: prefer older libraries
#export LD_RUN_PATH="${LD_RUNPATH}:${GCCBASE}/lib/../lib64"

# Man should also find the newer manpages
export MANPATH="${MANPATH}:${GCCBASE}/share/man"


Please note: /opt is *NOT* in ld.so.conf, and should not be


Later versions

You may find that still later versions are available. Check /opt/netapps/gnu/gcc, and alter the above script by adjusting the line

GCCBASE="/opt/netapps/gnu/gcc/5.2"