Author Topic: Associate compiler to file extension  (Read 599 times)

Offline some_teacher

  • Single posting newcomer
  • *
  • Posts: 2
Associate compiler to file extension
« on: February 18, 2019, 11:42:13 am »
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!

Offline gd_on

  • Regular
  • ***
  • Posts: 494
Re: Associate compiler to file extension
« Reply #1 on: February 18, 2019, 01:33:41 pm »
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 10, svn C::B (last version or almost!), WxWidgets 3.1.3, Compilers 8.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\MinGW64) or 32 bits (sjlj, posix in C:\MinGW32).

Offline some_teacher

  • Single posting newcomer
  • *
  • Posts: 2
Re: Associate compiler to file extension
« Reply #2 on: February 19, 2019, 09:38:38 am »
Aha, I tried and it does work. I usually compile manually or through makefiles myself, so I am quite rusty regarding IDEs. Thanks!