Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: gib on July 07, 2017, 10:50:51 pm
-
Is it possible in CB to compile a single file in the list of target files? This can be done in Visual Studio.
-
I'm not sure I understand the question. Can you try to describe it with more details?
-
Say I have a project composed of several files. Instead of building the target completely I want to test compilation only of a single file. You might question why anyone would want to do this. I have occasionally had reason to do this using VS, and I'm just wondering if it's possible in CB.
-
Select the file you wish to compile in the Project Tab in the Management Window.
Right Click and choose "Build File"; you might need to do "Clean File" first.
Tim S.
-
Thanks! I feel pretty stupid not to have seen that. I guess I was looking for 'compile', not 'build'.
There seems to be an issue with MinGW Fortran, though, in my CB version at any rate (13.12):
mingw32-gfortran.exe -J -c D:\trophocell3D-abm\src\fmotion.f90 -o \src\fmotion.o
D:\trophocell3D-abm\src\fmotion.f90:4.4:
use global
1
Fatal Error: File 'global.mod' opened at (1) is not a GFORTRAN module file
The file I am compiling uses module global, which does exist (obviously) - the target DLL builds OK. Interestingly it finds global.mod but doesn't recognise it. This not a problem, in any case.
-
The error when I try to build a file that doesn't USE any modules is a strange one:
mingw32-gfortran.exe -J -c D:\trophocell3D-abm\src\par_zig_mod.f90 -o \src\par_zig_mod.o
D:\trophocell3D-abm\src\par_zig_mod.f90:256.22:
END MODULE par_zig_mod
1
Fatal Error: Can't open module file '-c/par_zig_mod.mod0' for writing at (1): No such file or directory
This file defines a module.
<edit> The problem is that '-J' with nothing after it. When I invoke the compile line at the command prompt there is a warning about "nonexistent include directory '-c'". If I remove the '-J' it compiles. This presumably has something to do with how cmake created the make files - this project was made with cmake. Another reason to create a project in CB. :)
-
Just to wrap this up: if the project was created within CB, 'Build file' for this project works exactly as you'd expect.