Code::Blocks

User forums => Using Code::Blocks => Topic started by: some_teacher on February 18, 2019, 11:42:13 am

Title: Associate compiler to file extension
Post by: some_teacher 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!
Title: Re: Associate compiler to file extension
Post by: gd_on 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...
Title: Re: Associate compiler to file extension
Post by: some_teacher 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!