2

I am confused by the versions I have on my machine. I am running Ubuntu 16.04.

The output of gcc --version and g++ --version tells me that I have 7.2.0 installed. Great!

When I do gfortran --version however, it tells me that I have 5.4.1 installed. When I updated (sudo apt-get install gfortran-7), it correctly updated and now tells me that I already have the newest version. And when I do gfortran-7 --version it correctly identifies the version. How can I tell the system that there is a newer version of gfortran "available" on my system? How do I overwrite this?

edit: I already followed Cannot find -lgfortran but the symbolic link is already existant on my drive, so I tried updating and got to the above problem.

edit2: Additionally I just found out with gfortran -v that this gfortran still thinks gcc is at version 5.4.1 as well. :S

edit3: The output of apt-cache policy gcc gfortran is:

gcc:
  Installed: 4:5.3.1-1ubuntu1
  Candidate: 4:5.3.1-1ubuntu1
  Version table:
 *** 4:5.3.1-1ubuntu1 500
        500 http://de.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        100 /var/lib/dpkg/status
gfortran:
  Installed: 4:5.3.1-1ubuntu1
  Candidate: 4:5.3.1-1ubuntu1
  Version table:
 *** 4:5.3.1-1ubuntu1 500
        500 http://de.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        100 /var/lib/dpkg/status

The output of gcc -v is

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.2.0-1ubuntu1~16.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.2.0 (Ubuntu 7.2.0-1ubuntu1~16.04) 

The output of gfortran -v is

Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.1-2ubuntu1~16.04' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.1 20160904 (Ubuntu 5.4.1-2ubuntu1~16.04) 

edit4: The output of whereis -b gcc gfortran gfortran-7 is

gcc: /usr/bin/gcc /usr/lib/gcc
gfortran: /usr/bin/gfortran
gfortran-7: /usr/bin/gfortran-7
fxm
  • 123
  • 1
  • 6
  • Edit https://askubuntu.com/posts/948343/edit your Question and, using (Copy-And-Paste, Select pasted text, format with `{}` tool) the commands and results of `apt-cache policy gcc gfortran`, `gcc -v`, `gfortran -v`. – waltinator Aug 21 '17 at 15:40
  • Done. Thanks! I don't fully understand, but I feel that `apt-cache policy gcc gfortran` shows that older versions are still being used. (as did `gfortran -v`) – fxm Aug 22 '17 at 08:06
  • It looks like you installed gcc-7 / g++-7 / gfortran7 from source - hence `apt` knows nothing about them. Perhaps you symlinked gcc and g++ to gcc-7 and g++-7 but didn't do the same for gfortran? – steeldriver Aug 22 '17 at 08:14
  • There is no package `gfortran-7` in 16.04, this package will only be available in 17.10. What Ubuntu version do you use? – dessert Aug 22 '17 at 08:35
  • @dessert: I am using 16.04 (just checked again!) @steeldriver: Hmm, at least gfortran-7 I installed yesterday via `sudo apt-get install gfortran-7`, but I remember having a small problem with the others. How would I link them though? – fxm Aug 22 '17 at 08:38
  • Did you install these packages without using `apt` or `dpkg`? If so, no wonder it can't find them… – dessert Aug 22 '17 at 08:42
  • I am uncertain about gcc and g++ (and maybe I will remove and re-install them) but at least gfortran-7 I installed via apt (`sudo apt-get install`) yesterday. But how could I have installed them otherwise? I didn't use a tarball and set up everything myself, at most I used a different command than `sudo apt-get`. – fxm Aug 22 '17 at 08:44
  • Maybe you added a PPA that provides the `gfortran-7` package? Does [this](https://askubuntu.com/a/581497/507051) help? – dessert Aug 22 '17 at 08:53
  • Please provide the outputs of `whereis -b gcc gfortran gfortran-7`. – dessert Aug 22 '17 at 08:56
  • I added the output of `whereis`to the question. And yes I do have the Ubuntu toolchain ppa and I remeber using it when installing gcc and g++! I didn't use it (explicitly) when installing gfortran-7 yesterday though. I had found the link you provided, but as I only needed one version of all of them to run, I thought it would not help me. – fxm Aug 22 '17 at 10:55

1 Answers1

0

There is some confusion with different versions of packages here, I suggest you remove all of those packages with

sudo apt remove gcc gcc-7 g++ g++-7 gfortran gfortran-7

first and then do a clean install of just the (-7) packages you want. This way the system should get configured correctly. If you encounter problems, follow the instructions in this related answer.

dessert
  • 39,392
  • 12
  • 115
  • 163
  • Okay, I removed all of them and then installed `gcc-7`, `g++-7` and `gfortran-7`. Now for `whereis X-7` it always finds something. I'll test around with it and definetily learned a couple of things here. Thank you! – fxm Aug 23 '17 at 10:11