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.

#include search path issues for Grace generated files



I'm using Grace 2.0 with CCS 5.3. installed on Windows 8 64bit

within the Timer0 ISR I would like to increment a counter which is defined in a user defined header file (main.h). When I include this header file in the "InterruptVectors_init.c" file the compiler complains that it cannot find the "main.h" file. I have specifically included the directory in the search path for the build options, yet to no avail.

Is there some special place where I should be declaring the search path for #include statements that Grace uses for the InterruptVectors_init.c compilations? 

Steps to reproduce:
1) Create a new empty MSP430 CCS Grace 2.0 project
2)  Enable Timer0 and click the "Capture/compare interrupt enable 0" checkmark in the "Basic User" mode
3) Create a new "main.h" header file in the main Project Directory
4) Right click on the project and select “properties”
5) Add the Project Directory into the search path under Build->MSP430 Compiler->Include Options
6) Open "InterruptVectors_init.c" and insert  #include "main.h" in the /* User defined includes, defines, global variables and functions */ section.
7) Build the project and notice the following error: "could not open source file "main.h" -> InterruptVectors_init.c /test3/src/grace line 23 C/C++

 Thanks in advance for your help.

 

  • Hi,

    have you also added the path to the linker file search path?   Also, could you please post the exact console output?    Then I can see if I can reproduce this here.

    Best Regards,
    Lisa

  • As suggested I added the path to the linker as well, however this had no impact. Attached file includes the console output

     

    Thanks for your help.

     

    **** Build of configuration Debug for project mytest ****
    
    "C:\\ti\\ccsv5\\utils\\bin\\gmake" -k all 
    making ../src/grace/grace.lib ...
    cle430 Grace_init.c ...
    "C:/ti/ccsv5/tools/compiler/msp430_4.1.5/bin/cl430" --abi=eabi -c --obj_directory=objs/  -vmsp --symdebug:dwarf --optimize_with_debug -qq -pdsw225  -D__MSP430G2553__ -I "C:/ti/ccsv5/tools/compiler/msp430_4.1.5/include" -I "C:/ti/grace_2_00_01_65/packages"  -I "C:/ti/ccsv5/ccs_base/msp430/include" -I "C:/ti/ccsv5/ccs_base/msp430/MSP430ware_1_40_00_24/packages/../" "Grace_init.c"
    cle430 CSL_init.c ...
    "C:/ti/ccsv5/tools/compiler/msp430_4.1.5/bin/cl430" --abi=eabi -c --obj_directory=objs/  -vmsp --symdebug:dwarf --optimize_with_debug -qq -pdsw225  -D__MSP430G2553__ -I "C:/ti/ccsv5/tools/compiler/msp430_4.1.5/include" -I "C:/ti/grace_2_00_01_65/packages"  -I "C:/ti/ccsv5/ccs_base/msp430/include" -I "C:/ti/ccsv5/ccs_base/msp430/MSP430ware_1_40_00_24/packages/../" "CSL_init.c"
    cle430 GPIO_init.c ...
    "C:/ti/ccsv5/tools/compiler/msp430_4.1.5/bin/cl430" --abi=eabi -c --obj_directory=objs/  -vmsp --symdebug:dwarf --optimize_with_debug -qq -pdsw225  -D__MSP430G2553__ -I "C:/ti/ccsv5/tools/compiler/msp430_4.1.5/include" -I "C:/ti/grace_2_00_01_65/packages"  -I "C:/ti/ccsv5/ccs_base/msp430/include" -I "C:/ti/ccsv5/ccs_base/msp430/MSP430ware_1_40_00_24/packages/../" "GPIO_init.c"
    cle430 BCSplus_init.c ...
    "C:/ti/ccsv5/tools/compiler/msp430_4.1.5/bin/cl430" --abi=eabi -c --obj_directory=objs/  -vmsp --symdebug:dwarf --optimize_with_debug -qq -pdsw225  -D__MSP430G2553__ -I "C:/ti/ccsv5/tools/compiler/msp430_4.1.5/include" -I "C:/ti/grace_2_00_01_65/packages"  -I "C:/ti/ccsv5/ccs_base/msp430/include" -I "C:/ti/ccsv5/ccs_base/msp430/MSP430ware_1_40_00_24/packages/../" "BCSplus_init.c"
    cle430 InterruptVectors_init.c ...
    "C:/ti/ccsv5/tools/compiler/msp430_4.1.5/bin/cl430" --abi=eabi -c --obj_directory=objs/  -vmsp --symdebug:dwarf --optimize_with_debug -qq -pdsw225  -D__MSP430G2553__ -I "C:/ti/ccsv5/tools/compiler/msp430_4.1.5/include" -I "C:/ti/grace_2_00_01_65/packages"  -I "C:/ti/ccsv5/ccs_base/msp430/include" -I "C:/ti/ccsv5/ccs_base/msp430/MSP430ware_1_40_00_24/packages/../" "InterruptVectors_init.c"
    "InterruptVectors_init.c", line 23: fatal error: could not open source file "main.h"
    1 fatal error detected in the compilation of "InterruptVectors_init.c".
    
    Compilation terminated.
    >> Compilation failure
    gmake[1]: *** [objs/InterruptVectors_init.obj] Error 1
    cle430 System_init.c ...
    "C:/ti/ccsv5/tools/compiler/msp430_4.1.5/bin/cl430" --abi=eabi -c --obj_directory=objs/  -vmsp --symdebug:dwarf --optimize_with_debug -qq -pdsw225  -D__MSP430G2553__ -I "C:/ti/ccsv5/tools/compiler/msp430_4.1.5/include" -I "C:/ti/grace_2_00_01_65/packages"  -I "C:/ti/ccsv5/ccs_base/msp430/include" -I "C:/ti/ccsv5/ccs_base/msp430/MSP430ware_1_40_00_24/packages/../" "System_init.c"
    cle430 WDTplus_init.c ...
    "C:/ti/ccsv5/tools/compiler/msp430_4.1.5/bin/cl430" --abi=eabi -c --obj_directory=objs/  -vmsp --symdebug:dwarf --optimize_with_debug -qq -pdsw225  -D__MSP430G2553__ -I "C:/ti/ccsv5/tools/compiler/msp430_4.1.5/include" -I "C:/ti/grace_2_00_01_65/packages"  -I "C:/ti/ccsv5/ccs_base/msp430/include" -I "C:/ti/ccsv5/ccs_base/msp430/MSP430ware_1_40_00_24/packages/../" "WDTplus_init.c"
    gmake[1]: Target `all' not remade because of errors.
    gmake: *** [../src/grace/grace.lib] Error 2
    'Building file: ../main.cfg'
    'Invoking: XDCtools'
    "C:/ti/xdctools_3_24_05_48/xs" --xdcpath="C:/ti/grace_2_00_01_65/packages;C:/ti/ccsv5/ccs_base/msp430/MSP430ware_1_40_00_24/packages;C:/ti/ccsv5/ccs_base;" xdc.tools.configuro -o configPkg -t ti.targets.msp430.elf.MSP430 -p ti.platforms.msp430:MSP430G2553 -r debug -c "C:/ti/ccsv5/tools/compiler/msp430_4.1.5" --compileOptions "--symdebug:dwarf --optimize_with_debug" "../main.cfg"
    making package.mak (because of package.bld) ...
    generating interfaces for package configPkg (because package/package.xdc.inc is older than package.xdc) ...
    configuring main.xe430 from package/cfg/main_pe430.cfg ...
    error: xdc.cfg.SourceDir: "C:/ti/xdctools_3_24_05_48/packages/xdc/cfg/SourceDir.xs", line 163: xdc.cfg.SourceDir : Build of generated source libraries failed: exit status = 2:
    "InterruptVectors_init.c", line 23: fatal error: could not open source file "main.h"
    1 fatal error detected in the compilation of "InterruptVectors_init.c".
    Compilation terminated.
    gmake[2]: *** [objs/InterruptVectors_init.obj] Error 1
    gmake[1]: *** [C:/Users/Ken/workspace_v5_3/mytest/src/grace/grace.lib] Error 2
    
    js: "C:/ti/xdctools_3_24_05_48/packages/xdc/cfg/Main.xs", line 149: Error: Configuration failed!
    gmake.exe: *** [package/cfg/main_pe430.xdl] Error 1
    gmake.exe: *** Deleting file `package/cfg/main_pe430.xdl'
    gmake.exe: *** [package/cfg/main_pe430.xdl] Deleting file `package/cfg/main_pe430.h'
    gmake.exe: *** [package/cfg/main_pe430.xdl] Deleting file `package/cfg/main_pe430.c'
    js: "C:/ti/xdctools_3_24_05_48/packages/xdc/tools/Cmdr.xs", line 51: Error: xdc.tools.configuro: configuration failed due to earlier errors (status = 2); 'linker.cmd' deleted.
    gmake: *** [configPkg/compiler.opt] Error 1
    gmake: Target `all' not remade because of errors.
    
    **** Build Finished ****
    

  • Hi,

    no worries.  I wonder whether this is a COFF vs ELF issue.  In your project settings, could you please check Project->Properties->General and under Output format do you have eabi(ELF) or COFF?

    Best Regards,
    Lisa

  • It was listed as eabi(ELF). I changed it to COFF but this didn't seem to help.

     

     

  • I made a simple test project if this helps to trouble shoot the configuration issues. Please see attached...

    1731.MyTest.zip

  • Hi,

    I can reproduce this here and will get back to you as soon as I have any feedback on what might be going on. 

    Best Regards,
    Lisa

  • Hi,

     

    just wondering if there is a workaround ID'd yet for this - kind of stuck moving forward at this point.

    Thanks,
    KF

  • Hi,

    we are able to reproduce it and are still investigating.  I will post feedback as soon as we have some.  Development is involved, but we are not sure quite yet what the root cause.

    Best Regards,

    Lisa

  • KF,
    the command line that compiles InterruptVectors_init.c is automatically generated, and as far as I can tell there is no a convenient way to add an include directory to the include path. The changes in the project properties do not make any difference because the project properties affect only compilation of your source files, not the files that are automatically generated.

    I'll look more for a workaround. There is always the option of making changes directly in your Grace installation, but we should try to avoid that if possible. I'll post again when I find something.

  • KF,
    there is a way to add options to the command line that builds InterruptVectors_init.c, but for some reason I needed to clean and rebuild twice to see the effect. Go to Project Properties->CCS Build->XDCtools->Advanced Options->Additional compiler options. There might be a string "--symdebug:dwarf --optimize_with_debug" already specified there. Add your project directory as an include path there, and that should make your header file visible to the compiler.

  • I added "--symdebug:dwarf --optimize_with_debug --include_path="C:/Users/KF/workspace_v5_3/MyTest"" to the location specified. However this only partially works.

     

    The main.h file is found - and if this file is empty the compiler doesn't seem to complain. However, as soon as I add a declaration such as "int Counter;" this causes errors in compilation again.

  • What's the error?

    Also, "int Counter;" is a definition, not a declaration and it's rarely a good idea to have a definition in a header file.

  • OK fair enough. I wont increment the counter directly in the ISR, instead I call a function in the ISR that increments the counter from within main.c. This seems to have resolved the compile errors and I can progress from here.

     

    Thanks to both you and Lisa for your excellent help.

     

     

  • KF,

    You can still do what you wanted, just slightly differently.

    In your main.h file, instead of defining:

    int counter;

    use

    extern int counter;

    then create the global variable in your main.c file

    int counter;

  • Sasha Slijepcevic said:
    Also, "int Counter;" is a definition, not a declaration and it's rarely a good idea to have a definition in a header file.

    While this is technically correct and I agree about definitions in header files (and #including .c files), it is a 'weak' definition and treated by any C standard as a declaration as well, leaving the instantiation to the linker.

    You won't find many header files (except for standalone headers like the MSP430.h) without this kind of weak definition. No compiler should choke on it. No compiler I used ever did.

  • Jens-Michael,
    thanks, I learned something new.
    However, TI compilers for C2000 and C6000 did report errors. I think there is a pragma to support weak symbols, but I couldn't find it documented. 

  • Sasha Slijepcevic said:
    However, TI compilers for C2000 and C6000 did report errors

    This is strange, as it is different than all compiler I worked with. But it may have a reason (see below).

    I guess they don't report an error on "void foo(void);"? Which is also a declaration rather than a definition, even though it doesn't have (and require) an 'extern'.

    As long as a variable definition doesn't contain an initialization, the standard treats it as a declaration. However, there is a difference. While a variable declared as extern causes the compiler just to reference it (and if it isn't defined anywhere, the linker will complain about an unresolved reference later), using an incomplete definition (without initialization) causes the compiler to just declare its existence to the linker. If no initialization is found anywhere, the linker just puts it into the uninitialized (usually auto-zeroed) variable space.

    However, this contains a risk: Multiple independent modules may define a variable with the same name this way. The compiler won't complain and the linker will merge them, which might be not the intention. An explizit initialization in the two .c files (even if to zero) would instead throw a linker error and show the problem to the coder.
    But this problem may also occur if you just have the same incomplete definition in two modules (independent of header files) for a module - internal variable. If you don't add a 'static' attribute to it, the same merging may occur.

    The C standard says nothing about this, as it is the responsibility of the coder to pick different names for different variables. Or explicitely declare them as local :)

  • I have a similar problem using Grace with CCS 5.3.0:

    I created within the project space a new header file and included it in the Grace file "InterruptVectors_Init.c".

    Despite the fact that I added my Project Directory in the Compiler search path Options, the following fatal error occurs: "InterruptVectors_init.c", line 21: fatal error: could not open source file "LCD.h"

    The same header file is also referenced in main.c and works fine there.

    Any ideas how to fix this problem?

  • Thomas,
    have you tried the solution from my second post on March 26th in this thread?

  • Sasha,

    I tried your suggestion with the additional search path in the compiler Options:

     

    "--symdebug:dwarf --optimize_with_debug --include_path="D:\Daten\TI\MSP430_Projekte\LCD_2""

     

    and got the same error message as before:

    "InterruptVectors_init.c", line 21: fatal error: could not open source file "LCD.h"

  • Thomas,
    try cleaning the project first, and also you'll have to use forward slashes (D:/Daten/TI/MSP430_Projekte/LCD_2"). The path is used in JavaScript code and backslashes are treated as escape characters. If the builds still fails, please post the content of your console window.

  • Dear Sasha,

    thanks a lot, the back slashes caused the problem, now it works and you saved my day!

    Regards

    Thomas

  • Sasha Slijepcevic said:

    there is a way to add options to the command line that builds InterruptVectors_init.c, but for some reason I needed to clean and rebuild twice to see the effect. Go to Project Properties->CCS Build->XDCtools->Advanced Options->Additional compiler options. There might be a string "--symdebug:dwarf --optimize_with_debug" already specified there. Add your project directory as an include path there, and that should make your header file visible to the compiler.

    Just adding that this worked for me as well (CCS v5.4.0.00091).  And fantastically, when I added the project path and then moved to another project in the same workspace (so I could do the same for that project), it automagically updated the include path.  So where one project had:

    "--symdebug:dwarf --optimize_with_debug --include_path="C:/ccs_v5/MyProj_1""

    When I changed the active project to MyProj_2, then went to SDCtools' advanced options, the Additional compiler options string was already updated to look like this:

    "--symdebug:dwarf --optimize_with_debug --include_path="C:/ccs_v5/MyProj_2""

    That makes such a workaround so much easier!  thank you.

    ..dane

**Attention** This is a public forum