Question

I previously had some troubles updating old code that still needed a not supported compiler and expensive libraries to a version with gfortran in Eclipse on Windows. I let it rest for a while and recently I took a whole other approach, rebuilding the program from scratch, developping on a ubuntu machine, but now I want to bring it back to a windows machine so that my co-workers can contribute on it.

The status:

  • Program compiles, runs and gives good results on an ubuntu machine with the GCC GNU compiler
  • Windows 7 machine, 64bit
  • Cygwin installation (for gnu fortran) with lapack and liblapack-devel (however, I don't use these, because I compile blas and lapack manually)
  • (C:/cygwin/lib added to windows Path)

Original Issue:

The program compiles in cygwin (by calling the make-command, calling the make command with the makefile situated here: http://thijsvandenbrande.be/phd/hamfemInstall/makefile

This returns the file hamfem.exe which returns the following error when runned by double-clicking on it in windows: The program can't start because cyglapack-0.dll is missing from your computer. Try reinstalling the program to fix this problem.

When running the executable from cygwin, by calling the ./hamfem.exe command the executable starts to run. However, I want a solution so that I can give this executable to my co-workers so that they can change the input files (located in a folder in that has a relative path to the executable).

Going further on the comments below, I tried the next things:

  1. Adding the exact path to the C:\cygwin\lib\lapack\cyglapack-0.dll file in windows path and even rebooting afterwards doesn't help.
  2. adding a -static to the makefile before calling the library, resulting in dependency errors because I use two commands of the lapack library that depend on quite a lot of other commands (DPBTRF and DPBTRS). These commands are used in the mainprog.f90 module. The error: /usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../liblapack.a(dpbtrf.f.o): In function 'dpbtrf': /usr/src/debug/lapack-3.4.2-1/SRC/dpbtrf.f:277: undefined reference to 'dtrsm_' and a couple of more lines stating the dependencies.
  3. add the liblapack.a file to the src folder, but compiler always goes back to the lapack in cygwin

On the website of lapack you can normally download the functions with their dependencies (example DPBTRF), but these are not available anymore. Does anyone have another idea how to include these two functions and their dependencies in a static library-file that I can compile beforehand and add to the src-folder?

Current (semi-)Fix

The next thing worked (a bit) for me: following the instructions on http://gcc.gnu.org/wiki/GfortranBuild to manually build libblas.a and liblapack.a in the /usr/src folder of Cygwin and refering to this folder in the makefile. The updated makefile can be found here: http://thijsvandenbrande.be/phd/hamfemInstall/makefileNew

The code compiles nicely on Windows by running the make command from cygwin (next step in the process, running it out of Eclipse) and i get a .exe file that can be run by double clicking it and that keeps running if I move it with its folder to another location. Because this process is quite labour intensive, figuring it all out, I added the answer here below, stating the commands you have to parse to cygwin in order to make it work.

For your information: my file structure looks like this (after the build, I move the .exe file one folder up, both in the linux version as the windows version):

  • hamfem.exe
  • in
    • input.txt
    • NGCR_building01.txt
  • out
    • (empty folder for output files of the routine)
  • src
    • hamfem.f90 (main file)
    • mainprog.f90 (file that contains the commands from lapack)
    • ...(a bunch of other modules)
    • makefile
Was it helpful?

Solution

I figured things out myself, with some pointers from all over stackoverflow. In order for others to help them resolve similar issues, I would like my work method here so that the question is fully documented.

The issue can be resolved by clean building the Lapack library !and the Blas library on your local machine in cygwin and pasting the liblapack.a and libblas.a file to the library folder that you refer to in the makefile. The errors that were casted by calling Lapack staticly where a result of some routines of Blas used in the two commands.

These are the steps I followed:

  1. download the lapack.tgz and blas.tgz files from the website and past them in the C:\Cygwin\usr\src folder
  2. Extract these files with the following commands in cygwin:

    cd /usr/src 
    tar -xvzf lapack.tgz
    tar -xvzf blas.tgz
    
  3. Build the two library files with the commands shown below in Cygwin. Compiling Lapack can take a while and will result in some errors in the end because of some missing links in the test files. These tests are run for accuracy tools. A more detailed look into the make.inc file is needed to resolve these issues.

    cd $HOME 
    cd /usr/src/BLAS
    make
    mv blas_LINUX.a ../libblas.a
    cd ../lapack-3.4.2
    mv make.inc.example make.inc
    make
    mv liblapack.a ../liblapack.a
    
  4. check the makefile included in this repository for the correct linking to the libraries. These should say /usr/src and -static -llapack -lblas, the other options are for the linux compiler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top