This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Including a header file outside the project folder results in errors

Hello everyone,

So I am puzzled with this problem. Clearly working with the compiler and linker is not my thing :<
I am using CCS v6 with the Tiva launchpad. I am using the TI compiler v5.2.4.

I have some pairs of header and source files in a folder. I wanted to use them in some projects, since I wanted to not have multiple ones, one in each project I wanted to link the ones in the common folder.
So I added the folder path to the "include options" and then in my code I just added "#include "file.h" ".
Problem is it doesn't seem to be finding the source files in that folder! I get lots of "unresolved symbols". When I had the files inside the project folder I didn't have any problem.

If anyone could help me it would be appreciated.

  • Just try #include <file.h>.

    However, in similar situation we keep source tree in some organised fashion and refer sources and headers relative, as "../..path/folder/src.h"

  • I actually tried both "" and <> and it didn't work.

    Thanks for the reminder. I really have to remember to use variables and relative paths.
    I actually got it working, later I will try to explain how.
  • I once faced the same issue but got it resolved by simply restarting my PC :)

    Some kind of CCS Instability!

    Regards,

    Gautam

  • That's weird Gautam. Maybe you needed to rebuild instead of just build? CCS (and other IDEs) have those weird problems.


    Well so what I did to have some files working outside the project folder was:

    Add the folder path into the"Include Options" -> this will allow to had the header file
    Added the folder to the project by linking it (right click project->New->Folder-> Advanced -> link external folder) and that allowed the linker to know which source files to turn into objects so now the symbols it got by including the headers have a definition.
    Now in the main.h I added the files I wanted by doing #include <file.h>. And Now all works :)
  • Maybe you needed to rebuild instead of just build? CCS (and other IDEs) have those weird problems.

    Luis, I never "only" build my projects... I've an unusual habit of rebuilding the project every time :)
  • Really? I rarely even remember that the option is there (maybe I wouldn't have some problems if I did).
  • Really? I rarely even remember that the option is there (maybe I wouldn't have some problems if I did).


    Right Click on your Project -> Rebuild Project. As simple as that :)

    Regards,
    Gautam