Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Linking Fortran

  1. Feb 11, 2014 #1

    I would like to compile some *.for files (only standard Fortran77 statements) which only contains some subroutines and functions and link them with a *.res resource file and a *.lib library file (supplied by developers) into a windows executable.

    Is there any FREE program to achieve this?

    Some detail:
    -My operating system is Windows7
    -Previously I used the the trial version of an Intel program and it worked.
    -The *.exe I'm trying to recreate meant to be a modified version of an existing windows program, so that's why I need the *.res and the *.lib files.

    Thans for the answer!
  2. jcsd
  3. Feb 11, 2014 #2


    User Avatar
    Science Advisor

    Did you look up the gfortran compiler?
  4. Feb 11, 2014 #3
    No, not yet.
    Do you have experience with compiling windows executables in gfortran?
  5. Feb 11, 2014 #4


    User Avatar
    Science Advisor

    Well, I somtimes used gfortran under cygwin. There are also binary builds of the compiler around for windows, so it should be easy to try them out.
  6. Feb 16, 2014 #5
    I installed gfortran and tried it on some small programs.
    Now I would like to link my library file, and resouce file with my object files.
    So about the library:
    It only accepts files with a name like: libfilename.a (like in unix) and I have a filename.lib (windows). Is changeing the filename enough, or should i convert it somehow?
    About the .res file:
    On other forums they told me I should convert my filename.res into a filename.rc file, then with windres.exe convert that into an object file.
    Do you think that could work?
  7. Feb 18, 2014 #6
    So I'm using gfortran:
    -compile with gfortran.exe with the -c option to prooduce .o files
    -convert the .res resource file into an object file (.o) with res2coff.exe
    -use ld.exe to link the object files mentioned above and MY library file, and some other library files too provided by gfortran

    Now I can produce a windows application, but it needs some .dll in the same directory. So I put them together but it freezes when I try to run it, and the dialog from the resource file doesn't appear at all.

    Should I use other library files?
    Is MY renamed library file the one which causes the problem?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook