News:

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

Main Menu

Associate compiler to file extension

Started by some_teacher, February 18, 2019, 11:42:13 AM

Previous topic - Next topic

some_teacher

Hello all,

I am currently teaching an introductory course on numerical methods using Fortran (department policy). We give the students an archaic IDE (Force) which honestly I don't like. In the previous semester they learned C++ using Code::Blocks. Since it can do C/C++ and Fortran at the same time, I plan on telling them to just keep using Code::Blocks, helping them to properly configure it.

The thing is, while I was testing Code::Blocks I have encountered an issue: when I hit F9 to compile+run, I  usually get the 'undefined reference to _gfortran_st_write' error. This happens because it is trying to compile a Fortran source code (saved with .f extension) using gcc instead of gfortran. I can solve this by selecting gfortran as a default compiler, but then I have the opposite problem with C/C++ source files.

Is it possible to configure Code::Blocks so that it chooses the compiler according to the source file extension, or to solve this issue in any other way? The idea is not to have to manually switch the compiler every time.

Thanks a lot!

gd_on

Create a project. That's easy. I think you don't do that. In each project you define which compiler to use, which specific options to use...
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).

some_teacher

Aha, I tried and it does work. I usually compile manually or through makefiles myself, so I am quite rusty regarding IDEs. Thanks!