Menu

Need help with compiling and linking

Osito
2007-08-07
2012-09-26
  • Osito

    Osito - 2007-08-07

    I have been using Dev-C++ for a long time now, but mostly for simple projects with one .c file and one .h file. I'm working on something that's too big and complicated for that, so I've broken it up into multiple files. I can't get it to compile and link though. The only thing that works for me is adding all the files to the project, unchecking 'include in compilation' and 'include in linking' under Project Options, and then including the .c files directly in my main file. So in main.c, I have something like this:

    include <windows.h>

    include "chamber.h"

    include "chamber_globals.h"

    include "chamber_prototypes.h"

    include "utils.c"

    include "power.c"

    include "serial.c"

    It works fine except that when I make a change to one of the included .c files and click Compile, it doesn't seem to notice my change. If I use Rebuild All instead of Compile, it does. Is that how it's supposed to be? I would have thought that an include file, whether it's .c or .h, would have to be compiled each time you compile the whole thing.

    None of this would bother me except that I have to click Rebuild All, dismiss the dialog box, and click Run since there's no 'Rebuild All and Run' button like there is for compile.

    Can someone shed some light on what is going on, and maybe even help me get my project set up properly so that each .c file is compiled and linked as it should be?

    Thanks,
    Andy

     
    • Nobody/Anonymous

      The include files are not being checked because of the compiler options. In Tools > Compiler Options, uncheck "Use fast but imperfect dependency generation". It will longer to check dependencies, but everything should compile.

       
      • Osito

        Osito - 2007-08-07

        Thank you! That was exactly what I was looking for. Now that I have unchecked the box, clicking Compile and Run works the way I was expecting. Oddly enough, in Help it says Dev-C++ defaults to checking all dependencies and that you can disable it with the option. I'm pretty sure I've never touched that option, so I think Dev-C++ defaulted to the "fast but imperfect" option.

        Anyway, thanks for your help.
        Andy

         
    • Nobody/Anonymous

      Add all the files to the project, check 'include in compilation' and 'include in linking' under Project Options. Remove the .c files from the main file. Recompile all.

      If this doesn't work post the compile log. You need to be more descriptive of the problem than 'I can't get it to compile and link.' What exactly does it do? What are the error messages?

       
    • Osito

      Osito - 2007-08-07

      I shouldn't have asked two question at once. Sorry about that. Forget about the compiling and linking issue. That was mostly for background, to explain why I had it set up this way.

      What I really want to know is, with the way I have it set up, is it the expected behavior that the changes to the included .c files don't get compiled when you click Compile but they do if you click Rebuild All?

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.