Codeblocks can't find header files

后端 未结 3 666
醉话见心
醉话见心 2020-12-09 07:08

So a few hours ago I started learning c++ in codelite but I was getting frustated with, so I just got codeblocks and imported the project. But now whenever I try to compile

相关标签:
3条回答
  • 2020-12-09 07:27

    I know this is years later, but I've recently seen students following what I deem is frankly bad advice such as what is given above. For those learning c++ this functionality is NOT for you. To add headers you should simply check that you are using double quotes, instead of angled brackets i.e.

    #include "myheader.h"
    

    and NOT

    #include <myheader.h>
    

    Angled brackets are meant for libraries (informally) and adding a simple header file for you basic classes does not require you to change default search directories. The problem comes when someone else tries to run your code (assuming you're doing this for uni) and their IDE isn't setup to search for a "library" (your header) where it shouldn't be. Double quotes tells the compiler the files exist in your current relative directory. This way you can keep your main, headers and header implementation in one directory. Fiddling with your IDE should only be done when necessary. KISS

    0 讨论(0)
  • 2020-12-09 07:38

    Since I haven't found any Makro for

    #define 'hostname of device where compiler is located' // which is unique and not to be copied !
    

    I have now successfully used and included

    #include "myCompileEnv.h" 
    

    as a workaround with the comments above, which is located more central - above the project directories in CodeBlocks.

    0 讨论(0)
  • 2020-12-09 07:45

    You have to tell Codeblocks where to find the header files that you include. Try adding the full path to your '/Headers' in the include directories of codeblocks

    Goto 'Codeblocks menu > Settings > Compiler > Search directories > Add'.

    EDIT: Since your issue, however, is quite irrelevant to learning the C++ language itself, I suggest that you start with simpler programs, then move on to more complex ones. That, of course, unless you have previous experience with other programming languages

    0 讨论(0)
提交回复
热议问题