3

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?

Community
  • 1
  • 1
tvandenbrande
  • 348
  • 5
  • 21

1 Answers1

2

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.

  • Thanx for the quick answer. I did resolved the first problem by changing a setting. Eclipse automaticly makes it's own makefile from the project preferences. So I can't change much exept the build commands. There is one problem left: I don't have a lapack.mod file, only the library files (liblapack.a). – tvandenbrande Sep 28 '12 at 10:40
  • If you do not have the mod file, you certainly can not do `use lapack`. You have to call the subroutines directly as in Fortran 77 or make an interface block yourself. – Vladimir F Героям слава Sep 28 '12 at 11:33
  • Or download and build the Fortran 95 interface here http://www.netlib.org/lapack95/ – Vladimir F Героям слава Sep 28 '12 at 11:40
  • Thank you for the hint, and how is that done, calling them directly? Cause when I just use the `CALL DPBTRF(..)` for example in my code I get the following message: `/cygdrive/c/Users/thys/../../../../../Debug/Mainprog.f90:574: undefined reference to `_dpbtrs_'` – tvandenbrande Sep 28 '12 at 11:42
  • Show please the full output including the build command. But it is suspicious you have 2 underscores in the symbol. – Vladimir F Героям слава Sep 28 '12 at 11:48
  • edited the question, the new full output is shown at the bottom of the question. – tvandenbrande Sep 28 '12 at 11:54
  • And can you try running `dumpbin /symbols liblapack.a` in windows command line in the right directory? How do the names of the subroutines look like? And how did you build your lapack? – Vladimir F Героям слава Sep 28 '12 at 11:57
  • `dumpbin`was not recognized as an internal or external command, so that didn't do much. The subroutines are [http://www.netlib.org/lapack/double/dpbtrf.f ] and [http://www.netlib.org/lapack/double/dpbtrs.f ]. Building wasn't needed tot get the .a files with cygwin, it was just a part of that installation. – tvandenbrande Sep 28 '12 at 12:03
  • I know the subroutines, but how did you compiled the library? It is important to use the same options, namely for underscoring. (If you have the source, you can also compile the subroutines with your project.) – Vladimir F Героям слава Sep 28 '12 at 12:05
  • What I basicly did was installing the package in cygwin using their update procedure [ http://cygwin.com/cgi-bin2/package-grep.cgi?grep=lapack ]. In the devel-package there was a pre-compiled library [ http://cygwin.com/cgi-bin2/package-cat.cgi?file=liblapack-devel%2Fliblapack-devel-3.4.1-1&grep=lapack ]. I'm now downloading the source files, trying to compile it on my own. – tvandenbrande Sep 28 '12 at 12:16
  • 1
    You may also try to remove `-funderscoring` from your options, but AFAIK it should not be a problem and it is the default choice. I am more worried about your compilatin command `gfortran -L"C:\cygwin\lib" -o "HAMFEM-GNUfortran" ./FEM_shape_functions.o ./HAM_boundary_conditions.o ./HAM_material_library.o ./HAM_thermodynamics_library.o ./Hamfem.o ./Mainprog.o ./maths.o -l"C:/cygwin/lib/libblas.a" - l"C:/cygwin/lib/liblapack.a"` I would expect `-L"C:/cygwin/lib" -llapack -lblas` Please check if your liblapack.a is in this directory. – Vladimir F Героям слава Sep 28 '12 at 13:22
  • Your last comment made me thinking, and instead of pasting the path, i just put in the library name (lapack and blas), reuslting in -llapack and -lblas. The errors in the output are gone, only I get an error in Eclipse `Errors running builder 'CDT builder' on project 'Hamfem' java.lang.NullPointerException.` – tvandenbrande Sep 28 '12 at 13:33
  • Did you manage to compile the program? Can you run it in the cygwin command line? – Vladimir F Героям слава Sep 28 '12 at 14:12
  • It did manage to compile, in the Release folder there is now a file `Hamfem.exe`. Only when I run it, it gives the message `The program can't start because cyglapack-0.dll is missing from your computer. Try reinstalling the program to fix this problem.` – tvandenbrande Sep 28 '12 at 14:23
  • This means that the program is expecting a dll, but you have only a static library. Did you try to compile with `-static`? – Vladimir F Героям слава Sep 28 '12 at 17:15
  • Vladimir, I restarted working on this code, but run into some other problems with the -static command. I changed the question to a more detailed one, in order to make the problem clear. – tvandenbrande Jul 25 '13 at 15:10