News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

gfortran, and modules

Started by gib, September 03, 2010, 10:38:05 AM

Previous topic - Next topic

gib

I've just started using Code::Blocks (on Windows 7) and I'm very impressed with it.  I have managed to build a reasonably complex gfortran DLL project, and an executable that links to it.  In the process I encountered a couple of issues with modules, and I'm not sure if there is a way to deal with them in CB.  The first thing I noticed, after loading the 10 or so source files, was that the build command produced errors because it was trying to compile code before the modules used by the code had been compiled.  I manually compiled each file, in the required order, to get the whole project installed.  So my first question is this: is there a way to control the order in which files are compiled?  Later I discovered another couple of things about how CB handles modules.  Modules are not deleted when a "clean" is invoked.  In a way this is fortunate, because if they were removed I'd need to do the manual recompilation sequence after a clean, but it does create a potential problem when "stale" modules are left in the directory.  This created a puzzle for me when I changed the gfortran version, then couldn't get the executable to link to the DLL (after cleaning and rebuilding).  I eventually realized that the .mod files I was using had been built by the previous compiler version, and were in some way incompatible (I was getting "multiple definition" errors on linking).

Can I force CB to remove .mod files on a clean?

oBFusCATed

Are this mod files generated by an post build step or normal compiling?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

gib

The .mod files (Fortran 90 and later) are generated by the compile.

gd_on

#3
Some of the problems you mentioned are quite recurrent on the forum. Did you try a search with keywords : gfortran mod
or even : fortran mod
Among others you'll find this : http://forums.next.codeblocks.org/index.php/topic,12672.0.html

If you have problem with the order of compilation, set the compilation priority for the .f file which produce .mod file to a lower value than 50 (the default value), and don't use multithread compilations.

Nevertheless, the cleaning process is not solved. May be the solution proposed in the linked post, but I have not tried it.

gd_on
Windows 11 64 bits (25H2), svn C::B (last version or almost!), wxWidgets 3.3.2, Msys2 Compilers 16.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

gib

#4
All the .f90 files generate .mod files.  I need to control the order of compiling.
...
I have set the different priority levels, as you suggested, and now the build goes without a hitch.

Thanks a lot!

Gib

xunxun

Try to choose the module file -- build this file only to generate the module.
Regards,
xunxun

gib

Quote from: xunxun1982 on September 12, 2010, 08:57:31 AM
Try to choose the module file -- build this file only to generate the module.

Sorry, I don't understand this message. :(