Archive for April, 2012

follow-up: using multiple versions of gcc on Windows

Posted in Compiler, Computer, Fortran, gcc, Programming Languages, Software on April 23, 2012 by giorgiomcmlx

I got some mails in which I was asked to describe the solution to the “liblto_plugin-0.dll not found” problem a bit more detailed. So let us assume that you installed (or plan to do that) all versions of gcc previously obtained from as subdirectories of the folder “X:\myCompilers” (myCompilers might be a path name!). Let us further assume, for example, that you decided to call these subdirectories “gcc461” and “gcc470” according to the version numbers of the gcc suites during the installations. At least, this convention will turn out to be a smart idea. After having firstly saved the environment variables to disk and secondly having erased all references to gcc from them, you might then want to create a DOS batch file called “go_gcc.bat”, for example, in the root directory of drive “X:”. Two lines of this batch file then set two environment variables to the values required by a specific gcc version obtained from

set PATH=X:\myCompilers\gcc%1%2%3\bin;E:\Projekte\COMPILER\gcc%1%2%3\libexec\gcc\i686-pc-mingw32\%1.%2.%3;%PATH%
set EQ_LIBRARY_PATH=X:\myCompilers\gcc%1%2%3\i686-pc-mingw32\lib

Of course, you have to use the saved information about the path names on your PC in order to correctly substitute all the symbolic paths names used in this post. Finally, if you want to use gcc and thus start cmd, you only need to enter “X:\go_gcc 4 6 3” in order to enable version 4.6.3 of the gcc suite, for example. If you plan to install multiple versions of gcc, it is even smarter to use “gcc_x.y.z” as folder names, as you then only need to use a single batch variable that holds the value of “x.y.z”:

set PATH=X:\myCompilers\gcc_%1\bin;E:\Projekte\COMPILER\gcc_%1\libexec\gcc\i686-pc-mingw32\%1;%PATH%
set EQ_LIBRARY_PATH=X:\myCompilers\gcc_%1\i686-pc-mingw32\lib

You would want to start this batch file typing in “X:\go_gcc 4.6.3”.

I hope things are obvious now.


strange error message by GCC on Windows platform

Posted in Compiler, Computer, Fortran, Programming Languages, Software on April 22, 2012 by giorgiomcmlx

After having installed a second version of the GCC suite on the MS-Windows platform of my PC, it turned out to be impossible to use the gfortran front end of the older one. I had downloaded both editions from the web page.

When trying to link a program using the older gcc/gfortran version, I always got an error message that looked like “fatal error: -fuse-linker-plugin, but liblto_plugin-0.dll not found”. Unfortunately, even a very extensive web search did not help. As I had not changed the position of the old files in the directory tree, it must have been the installation routine that created that mess. Indeed, the problem turned out to be caused by the installation routine adding the paths to two directories of the newer gcc version at the beginning of two environment variables, i.e., the user variable EQ_LIBRARY_PATH, and the system variable PATH. Because the name of the file is still the same in the newer version, the older gcc suite detects a wrong version of that file and raises the error message. Obviously, the error message should rather read “gcc found a wrong version of …”.

Thus, the cure to the problem is to edit these two environment variables manually. After having saved their proper content to text files by typing “set > set.txt” and “path > path.txt” on the command line, e.g., erase all information related to the gcc versions from both variables. In order to change PATH permanently, you need to have admin privileges. After that, just use a batch file on the command line to set the content of both variables according to the version of gcc that you are going to use in that very session of the command interpreter and all is fine. At least, that’s how it worked for me.