Search code examples
eclipsefortranlapackphotran

Configuring LAPACK in Eclipse-Photran for fortran compiler on Windows


Update

Thank you Vladimir for the usefull insights in libraries. I took another approach, developping first in ubuntu (which was a lot easier then messing around with Eclipse/Cygwin/... and now I'm trying to port to windows, which goes rather ok, however I have some questions about that too, posted here: Problems with porting a fortran program from ubuntu to windows

Question

I currently have the following setup and can't get the lapack library configured so that my fortran code can compile:

  • Windows 7
  • Cygwin installation (for GNU fortran), added to the windows PATH
  • lapack and liblapack-devel installed with cygwin
    • resulting in liblapack.a and libblas.a in the folder C:/cygwin/lib

In my program I call the lapack library using the following code

program myProgram
    !use lapack (stays commented now)
    ...

In Eclipse I used the following setup (with the Photran package):

  • Fortran Project: executable GNU fortran on Windows (GCC toolchain)
  • GNU fortran compiler: gfortran ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}
  • GNU fortran linker: gfortran ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}

I compiled the libraries libblas.a and liblapack.a, to use as a static library, for windows and they are located in the C:/cygwin/lib folder. In the GNU fortran linker properties, the libraries were called lapackand blasin the folder C:/cygwin/lib. This results in a part -L"C:/cygwin/lib" -llapack -lblas in the {$COMMAND} section of the compiler and linker. (thanx to @vladimir-f for the help)

In the output there are no error messages left anymore. Only I got now the following error in Eclipse and no final .exe or bins:

Errors occured during the build.
    Errors running builder 'CDT Builder' on project 'Hamfem'
    Internal error building project Hamfem configuration
    Release
    java.lang.NullPointerException
Internal error building project Hamfem configuration
Release
java.lang.NullPointerException

However, the result of the build is still an executable, in this case called Hamfem.exe. Running this file results in the error message (instead of the routine): The program can't start because cyglapack-0.dll is missing from your computer. Try reinstalling the program to fix this problem.

That file is currently located in C:/cygwin/lib/lapack/ but I want that this file isn't needed to run the program, so I can run it on different computers. Can someone collaborate on this?

Second, when copy-pasting the .dll file in the folder where the .exe is located, it runs for a brief second, generating a stackdump file. I can't use the debugger in Eclipse-Photran due to the 'Building Workspace' error. Eclipse gives the message Binary not found when I want to run it in Eclipse as a local Fortran program. Any ideas how to resolve this problem?


Solution

  • The problem is here

    L/lib/lapack –llapack
    

    try to change it for

    -L/lib/lapack –llapack
    

    probably it is in you Makefile.

    i.e.

    gfortran -funderscoring -O3 -Wall -c -fmessage-length=0 -L/lib/lapack -llapack -o 
    

    And make sure lapack.mod is really in /lib/lapack which is probably C:\cygwin\lib\lapack on Cygwin.