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.

Compiler/TM4C123GH6PM: Erros including the c++ string library in a TI-RTOS project in CCS

Part Number: TM4C123GH6PM

Tool/software: TI C/C++ Compiler

I would like to use the to_string function and some other functions provided by the "string" library (not the string.h). Now I have some problems with #include <string>. I have added the path to the libcxx folder in the include options for the TI v20.2.1.LTS compiler. It now finds the string but I get almost 100 errors in the type_traits. Almost all of them like this: #66 expected a ";". Looking in the type traits, it doesn't seem like there are any ";" missing and I would be very surprised if there were any missing. I have tried switching to the GNU v9.2.1 since I suspected that the compiler isn't working properly, but I am not experienced in working with the gnu compiler and I couldn't get it to work that way either (different problems though). I have also tried including other libraries from the libcxx folder and i get similar problems. 

Is there anything special I have to do before being able to work with c++ libraries? Advice on working with either the TI compiler or the GNU compiler would be appreciated. Thanks in advance to everyone willing to help.

  • I can reproduce a similar problem if I do something like this ...

    // file.c
    #include <string>

    The problem is in file extension part of the name of the source file.  The usual solution is to change the file extension from  .c to .cpp.  For more details, please search the ARM compiler manual for the sub-chapter titled Specifying Filenames.

    Yannik Frenzel said:
    I have added the path to the libcxx folder in the include options

    Please don't do that.  The compiler automatically searches the sub-directories of the /include directory you already specify.

    Thanks and regards,

    -George

  • I am currently building my program within CCS and I would like to keep it that way, so I don't know how the information given in the Specifying filenames sub-chapter of the compiler Manual will help me if I don't start the compiler using the command line. Is there anyway to specify the filenames while using the build option inside CCS?

    I removed the libcxx folder from the include options and now I get the Error "#1965 cannot open source file "string"". My guess is that the compiler doesn't find the source file, but if I'm interpreting your comment correctly it shouldn't have any issues locating the "string" in the libcxx sub-directory, correct? How can I resolve the issue a different way?

  • Have you tried to change the name of the file?  In CCS, right click on the name of the file and choose Rename.  Don't change the base name of the file, just the extension.  For example, change my_source_file.c to my_source_file.cpp.

    Thanks and regards,

    -George

  • I cannot rename the file since it is not a source file I have written my self. It is part of the c++ standard libraries. It has the symbol for a header file (.h) in CCS and when i right click on it, it doesn't give me the option to rename it.

    When I try to include any of the header files from the libcxx folder it gives me the error #1965 cannot open source file "name of file".

    Thank you for your help and patience so far. Do you have any other suggestion for what I could try to include the files in the libcxx folder?

  • I'm confused.  A header file is not typically compiled directly.  That is, when the compile command is issued, the file named is not a header file, but a C or C++ source file.  

    Please conduct the problem build again.  In the Console (not Problems) view, use the icon Copy Build Log to capture all the build commands and messages in a text file.  When naming the file, be sure to use the file extension .txt.  Please attach that text file to your next post.

    Thanks and regards,

    -George

  • Here is the build log you requested. This is without having the libcxx as an include path.

    Maybe this will help clarify things. 

    #include <string>

    This is what I am doing what is causing the problems.

    7380.BuildLog.txt
    **** Build of configuration Debug for project empty_EK_TM4C123GXL_TI ****
    
    "C:\\ti\\ccs1000\\ccs\\utils\\bin\\gmake" -k -j 12 all -O 
     
    making ../src/sysbios/sysbios.aem4f ...
    gmake[1]: Nothing to be done for 'all'.
    Building file: "../empty.c"
    Invoking: ARM Compiler
    "C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-arm_20.2.1.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --include_path="C:/Users/Yannik/workspace_v10/empty_EK_TM4C123GXL_TI" --include_path="C:/Users/Yannik/workspace_v10/empty_EK_TM4C123GXL_TI" --include_path="C:/ti/tirtos_tivac_2_16_00_08/products/TivaWare_C_Series-2.1.1.71b" --include_path="C:/ti/tirtos_tivac_2_16_00_08/products/bios_6_45_01_29/packages/ti/sysbios/posix" --include_path="C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-arm_20.2.1.LTS/include" --define=ccs="ccs" --define=PART_TM4C123GH6PM --define=ccs --define=TIVAWARE -g --gcc --diag_warning=225 --diag_warning=255 --diag_wrap=off --display_error_number --gen_func_subsections=on --abi=eabi --preproc_with_compile --preproc_dependency="empty.d_raw" --cmd_file="configPkg/compiler.opt"  "../empty.c"
     
    >> Compilation failure
    subdir_rules.mk:9: recipe for target 'empty.obj' failed
    "../empty.c", line 62: fatal error #1965: cannot open source file "string"
    1 catastrophic error detected in the compilation of "../empty.c".
    Compilation terminated.
    gmake: *** [empty.obj] Error 1
    gmake: Target 'all' not remade because of errors.
    
    **** Build Finished ****
    

  • Thank you for the build log.

    I still don't understand why you cannot rename the source file empty.c to empty.cpp.  

    But, presuming you can't do that ... Consider using the compiler option --cpp_default.  It tells the compiler to presume files with the extension .c contain C++ source code.

    Thanks and regards,

    -George

  • Renaming the file worked. I was just confused in your original post about renaming the file, which file you told me to rename. I change empty.c to empty.cpp and that resolved the issue.

    Thank you for your patience and your help.

    Kind Regards

    -Yannik