News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Compile a single file

Started by gib, July 07, 2017, 10:50:51 PM

Previous topic - Next topic

gib

Is it possible in CB to compile a single file in the list of target files?  This can be done in Visual Studio.

oBFusCATed

I'm not sure I understand the question. Can you try to describe it with more details?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

gib

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. 

stahta01

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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

gib

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.

gib

#5
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. :)

gib

Just to wrap this up: if the project was created within CB, 'Build file' for this project works exactly as you'd expect.