Author Topic: Compile a single file  (Read 219 times)

Offline gib

  • Multiple posting newcomer
  • *
  • Posts: 31
Compile a single file
« 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10062
Re: Compile a single file
« Reply #1 on: July 07, 2017, 11:36:55 pm »
I'm not sure I understand the question. Can you try to describe it with more details?
<debugger plugin maintainer>
(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!]

Offline gib

  • Multiple posting newcomer
  • *
  • Posts: 31
Re: Compile a single file
« Reply #2 on: July 08, 2017, 12:28:34 am »
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. 

Online stahta01

  • Lives here!
  • ****
  • Posts: 5846
    • My Best Post
Re: Compile a single file
« Reply #3 on: July 08, 2017, 12:47:58 am »
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++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline gib

  • Multiple posting newcomer
  • *
  • Posts: 31
Re: Compile a single file
« Reply #4 on: July 08, 2017, 01:01:55 am »
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.

Offline gib

  • Multiple posting newcomer
  • *
  • Posts: 31
Re: Compile a single file
« Reply #5 on: July 08, 2017, 01:33:51 am »
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. :)
« Last Edit: July 08, 2017, 01:45:54 am by gib »

Offline gib

  • Multiple posting newcomer
  • *
  • Posts: 31
Re: Compile a single file
« Reply #6 on: July 08, 2017, 02:17:13 am »
Just to wrap this up: if the project was created within CB, 'Build file' for this project works exactly as you'd expect.