Concerning hint with CPP environment variable (...) from above:Well, you can hardly expect Code::Blocks or MinGW.org to bundle support for every obscure language (no offence) into the default install. Most people don't need Fortran, those that do need it just have to install support for it separately.
This rocks! It was indeed possible using this trick to compile the fortran files. However, there are still open "issues":
1.) One is required to install the F77 package from MinGW. GCC only does not work (missing the f2c library).
2.) Linking fails with:It looks like the linker thinks you want to compile a Windows GUI program, but your object files disagree and want to be a console program. Is your target set to "Console program" in your project properties?
D:\Devel\CodeBlocks\lib/libmingw32.a(main.o):main.c:(.text+0x106): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
This is true if linking without the "-lg2c" switch. However - even if I add this switch under "Other linker options" it still does not link. I am working on this - If I find a reason I'll tell. I believe that I am only missing a bit here.
Is there a way to see the full compile/link command issued by Code::Blocks IDE?Settings -> Compiler -> tab "Other" -> Compiler Logging -> Full command line :)
Well, you can hardly expect Code::Blocks or MinGW.org to bundle support for every obscure language (no offence) into the default install. Most people don't need Fortran, those that do need it just have to install support for it separately.Sure - the last thing I am expecting from a professional IDE is Fortran support. I would never use Fortran if I didn't have to. I just said that as an addition to thomas' message. The only thing I am trying to is to enable the G77 compiler since it is based on GCC which is fully supported by Code::Blocks.
It looks like the linker thinks you want to compile a Windows GUI program, but your object files disagree and want to be a console program. Is your target set to "Console program" in your project properties?Yes, it is set to a console program.
Settings -> Compiler -> tab "Other" -> Compiler Logging -> Full command line :)Great! Thanks to this I was able to reproduce what is happening. One has to use the way as described by thomas (above) but use not CPP but CC instead for the compiler variable. After that the Fortran programs at least compile (using gcc). Unfortunately for linking "mingw32-g++.exe" is used (Why?) instead of g77 which should be. And that's it finally. If I copy/paste the linker command and replace "mingw32-g++.exe" with "g77.exe" (interestingly even without -lg2c switch) the linking is done correctly. But I don't know how to setup this in Code::Blocks. Any hints?
...Be sure that the extra linker options _DO NOT_ have the "-w," (or was it "-m," ? ) argument...
-Wl,--export-all-symbols
In the Compiler Settings, programs, you can choose which program you're using for linking for your fortran compiler.That was it! I made a copy of the GCC-Compiler and replaced the required programs with g77.exe. Sor far so (very!) good. There is only a minor drawback: It seems as if CodeBlocks can only handle C and C++ extensions, right? Or can I add somewhere additional extension for CodeBlocks to detect fortran files as sourcecode? Why I'm saying this:
#define FORT_EXT "F"
else if (ext.Matches(CPP_EXT) ||
ext.Matches(C_EXT) ||
ext.Matches(CC_EXT) ||
ext.Matches(CXX_EXT)
)
return ftSource;
else if (ext.Matches(CPP_EXT) ||
ext.Matches(C_EXT) ||
ext.Matches(CC_EXT) ||
ext.Matches(CXX_EXT) || ext.Matches(FORT_EXT)
)
return ftSource;
This is hardcoded (unluckily). [...]Thanks for the hint. I'll give it a try and I'm quite sure it works. However - submitting a patch might not be a good idea. I believe this is clearely something to be generally thought of. I mean: Setting up (new) compilers is greatly modularised ind Code::Blocks. So should be for the file-extension. Another example: Some of my collegures using the ".c++" and ".h++" extension for their files so they are lost similary even if it's clearly a C++ domain. Why not making extension be generally freely defined? Maybe one could use the lexers (there are the extension provided anyway) to build ftSource and ftHeader...?!
please make a patch upload it to sourceforge.