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.

Why Won't this Compile

Other Parts Discussed in Thread: TM4C123GH6PM, TM4C129XNCZAD

I am using Code Composer Version: 6.0.1.00040.  I am trying to compile the simplest program you have ever seen and it fails.

My settings are the following:

-mv7M4 --code_state=16 --float_support=FPv4SPD16 --abi=eabi -me -g --gcc --define=PART_TM4C123GH6PM --define=TARGET_IS_BLIZZARD_RB1 --define=ccs="ccs" --define=UART_BUFFERED --display_error_number --diag_warning=225 --diag_wrap=off --ual -z -m"tester.map" --heap_size=0 --stack_size=512 -i"c:/ti/ccsv6/tools/compiler/arm_5.1.6/lib" -i"c:/ti/ccsv6/tools/compiler/arm_5.1.6/include" --reread_libs --warn_sections --display_error_number --diag_wrap=off --xml_link_info="tester_linkInfo.xml" --rom_model

The program I am trying to compile is:

#include <stdint.h>
#include <stdbool.h>
#include <algorithm>
#include <stdio.h>

int main(void) {
std::string s1;
s1="HELLO";
while (1){

}
}

If I comment out the #include <algorithm> it doesn't get the 97 errors but the std::string fails.  Can someone try this and let me know what I am doing wrong.  I know the program doesn't really do anything but why won't it compile?

I have been working on this for two days.

  • Hi Donald,

         I have not tried C++ at CCS. But, try adding #include <iostream>, and see if you still get the same errors. Alternatively, you can ask this at CCS forum to get more expert advice.

    - kel

  • Hello Donald,

    I named the file as a cpp and added #include <string> and it compiles clean

    **** Build of configuration Debug for project TM4C129_CppCode ****

    "C:\\ti\\ccsv5\\utils\\bin\\gmake" -k all
    'Building file: ../TM4C129_CppCode.cpp'
    'Invoking: ARM Compiler'
    "C:/ti/ccsv5/tools/compiler/arm_5.1.1/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 --abi=eabi -me -O2 -g --include_path="C:/ti/ccsv5/tools/compiler/arm_5.1.1/include" --include_path="C:/ti/TivaWare_C_Series-2.1.0.12573" --gcc --define=ccs="ccs" --define=PART_TM4C129XNCZAD --define=TARGET_IS_TM4C129_RA1 --diag_warning=225 --display_error_number --diag_wrap=off --gen_func_subsections=on --ual --preproc_with_compile --preproc_dependency="TM4C129_CppCode.pp"  "../TM4C129_CppCode.cpp"
    'Finished building: ../TM4C129_CppCode.cpp'

    Regards

    Amit

  • Amit thank you very much.  I had a sample program and it compiled clean with std::string and it never occurred to me that it had a .cpp file extension.  Believe me I tried it with all combination of includes.  Thanks to you I have at least one grey hair left to pull out!!

    Now that it compiles using CCS I need to find out how to get it to compile under the new gcc under CCSv6.  Running into the COW problem, copy on write.  I don't know that much about gcc.  They say that if it accepts #include <thread> that is something to do with C11 what ever that is.  Would you know a substitute command or work around for std:: in gcc? 

  • Donald Varela said:
    Now that it compiles using CCS I need to find out how to get it to compile under the new gcc under CCSv6.  Running into the COW problem, copy on write.  I don't know that much about gcc.  They say that if it accepts #include <thread> that is something to do with C11 what ever that is.  Would you know a substitute command or work around for std:: in gcc? 

    What does the "the COW problem" mean?

    i.e. is that a compile or run-time problem?

    The following compiles and runs OK using the TI ARM 5.1.7 compiler:

    /*
     * main.cpp
     */
    
    #include <iostream>
    #include <string>
    
    int main(void) {
    	std::string s1;
    	s1="Hello";
    	s1 += " World";
    	std::cout << s1 << std::endl;
    	return 0;
    }
    

    However, I haven't got it to run yet using the GNU v4.7.4 (Linaro) compiler which came with CCS v6. The program is crashing in the constructor for std:string s1. It looks like a library compiled for ARM mode is being linked, whereas a TM4C129 only supports Thumb mode.

  • Hello Donald,

    I switched the compiler and it works...

    'Building file: ../TM4C129_CppCode.cpp'
    'Invoking: GNU Compiler'
    "C:/ti/ccsv5/tools/compiler/gcc-arm-none-eabi-4_7-2012q4/bin/arm-none-eabi-gcc.exe" -c -mcpu=cortex-m4 -mthumb -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DPART_TM4C129XNCZAD -I"C:/ti/ccsv5/tools/compiler/gcc-arm-none-eabi-4_7-2012q4/arm-none-eabi/include" -I"C:/ti/TivaWare_C_Series-2.1.0.12573" -ffunction-sections -fdata-sections -g -gstrict-dwarf -Wall -MMD -MP -MF"TM4C129_CppCode.d" -MT"TM4C129_CppCode.d" -o"TM4C129_CppCode.o"  "../TM4C129_CppCode.cpp"
    'Finished building: ../TM4C129_CppCode.cpp'
    ' '

    Regards

    Amit

  • I am using this website to set up my gcc since I know nothing about gcc.  http://processors.wiki.ti.com/index.php/Using_GCC_with_Tiva_in_CCSv6

    I have put in and left off the "c" "gcc" and "nosys" but I get the following errors.

    **** Build of configuration Debug for project GCCTest ****

    "c:\\ti\\ccsv6\\utils\\bin\\gmake" -k all
    'Building target: GCCTest.out'
    'Invoking: GNU Linker'
    "c:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/bin/arm-none-eabi-gcc.exe" -march=armv7e-m -mthumb -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DPART_TM4C123GH6PM -DTARGET_IS_BLIZZARD_RB1 -ffunction-sections -fdata-sections -g -gstrict-dwarf -Wall -Wl,-Map,"GCCTest.map" -L"C:/ti/TivaWare_C_Series-2.1.0.12573/driverlib/gcc" -o"GCCTest.out" "./main.o" "./tm4c123gh6pm_startup_ccs_gcc.o" -Wl,-T"../tm4c123gh6pm.lds"
    ./main.o: In function `main':
    C:\Users\Owner\workspace_v6_0\GCCTest\Debug/../main.cpp:24: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()'
    C:\Users\Owner\workspace_v6_0\GCCTest\Debug/../main.cpp:25: undefined reference to `std::string::operator=(char const*)'
    C:\Users\Owner\workspace_v6_0\GCCTest\Debug/../main.cpp:28: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
    C:\Users\Owner\workspace_v6_0\GCCTest\Debug/../main.cpp:28: undefined reference to `__cxa_end_cleanup'
    ./main.o:(.ARM.extab.text.main+0x0): undefined reference to `__gxx_personality_v0'
    c:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/armv7e-m/softfp\libg.a(lib_a-exit.o): In function `exit':
    exit.c:(.text.exit+0x16): undefined reference to `_exit'
    collect2.exe: error: ld returned 1 exit status
    gmake: *** [GCCTest.out] Error 1
    gmake: Target `all' not remade because of errors.

    **** Build Finished ****

    I have another program with std::string and it gives me this:

    c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
    gmake: *** [src/test.o] Error 1

    I don't have any idea on  how to invoke these commands!  This is what I was talking about with COW.  Copy on write is what causes this std:: violation.  Anyway that's what a found on some of the websites. 

  • Hello Donald

    Instead of using gcc.exe use the g++.exe for CPP files.

    Also any reason why you would like to use GCC instead of the native ARM compiler for CPP.

    Regards

    Amit

  • No I am quite happy with the arm compiler.  I thought I would try the gcc to see how it works and of course the first program I tried blew up on me.  You said I can use the g++ compiler.  The only compilers listed is the arm 5.1.6, 5.1.7 and gnu 4.7.4.  I,m 65 years old I will use the easiest thing that works.  Don't have much time left to do otherwise ha ha!

    I guess my ultimate question is are we the users going to be able to use std:: (anything) using the gcc compiler?

  • Donald Varela said:
    I have put in and left off the "c" "gcc" and "nosys" but I get the following errors.

    Try adding the stdc++ library as per the following:

    Also, when creating new Tiva projects using the GNU v4.7.4 compiler I found some errors in the default project settings used by CCS v6 which can cause run time failures - see Errors in CCSv6 created project for a TM4C129 project using the GNU v4.7.4 compiler

  • Making these changes works.  Before I close this issue and there are probably more people than myself would like to know, where is the documentation on the "c", "gcc" etc.found?

  • Donald Varela said:
    Before I close this issue and there are probably more people than myself would like to know, where is the documentation on the "c", "gcc" etc.found?

    There are the following GNU web pages which give documentation for the different libraries:

    https://www.gnu.org/software/libc/manual

    https://gcc.gnu.org/onlinedocs/gccint/Libgcc.html

    http://gcc.gnu.org/onlinedocs/libstdc++

    The gcc-arm-none-eabi-4_7-2013q3 compiler uses the Red Hat “newlib” version of the standard ANSI C library, which is for use on an embedded system. See ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/share/doc/gcc-arm-none-eabi/html/libc/index.html in the CCSv6 installation for the newlib documentation.

  • Thanks for the info.  I think I'm going to go back to the ARM compiler.  Just got through compiling and linking a program and got the following:


    **** Build of configuration Debug for project TM1638 ****

    "c:\\ti\\ccsv6\\utils\\bin\\gmake" -k all
    'Building target: TM1638.out'
    'Invoking: GNU Linker'
    "c:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/bin/arm-none-eabi-gcc.exe" -march=armv7e-m -mthumb -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -DDEBUG -DPART_TM4C123GH6PM -Dgcc -DTARGET_IS_BLIZZARD_RB1 -Os -ffunction-sections -fdata-sections -g -gstrict-dwarf -Wall -Wl,-Map,"TM1638.map" -L"C:/ti/TivaWare_C_Series-2.1.0.12573/driverlib/gcc" -o"TM1638.out" "./tm4c123gh6pm_startup_ccs_gcc.o" "./src/TM1638.o" "./src/test.o" -Wl,-T"../tm4c123gh6pm.lds" -Wl,--start-group -l"c" -l"gcc" -l"nosys" -l"driver" -l"stdc++" -Wl,--end-group
    c:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/bin/ld.exe: TM1638.out section `.text' will not fit in region `FLASH'
    c:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/bin/ld.exe: region `FLASH' overflowed by 103036 bytes
    collect2.exe: error: ld returned 1 exit status
    gmake: *** [TM1638.out] Error 1
    gmake: Target `all' not remade because of errors.

    **** Build Finished ****

    I know the program isn't very large.  I looked in the map and it doesn't tell you like on the ARM map how much is used.  It has

    Memory Configuration

    Name Origin Length Attributes
    FLASH 0x00000000 0x00040000 xr
    SRAM 0x20000000 0x00008000 xw
    *default* 0x00000000 0xffffffff

    Any ideas?

    I think I inserted the map file.  I used the paperclip, but I don't know where the file is.

  • Donald Varela said:
    Just got through compiling and linking a program and got the following:

    The GNU ARM compiler library takes more code space than the TI ARM compiler library.

    One way to reduce the code space used by the GNU ARM compiler library is to select "Remove unused sections (--gc-sections)" so that the linker doesn't link sections which aren't used:

  • That fixed the problem!  Thanks for all your help.  The problems and fixes found in this post needs to be in a WIKI such as http://processors.wiki.ti.com/index.php/Using_GCC_with_Tiva_in_CCSv6 so everyone can use them.

    My very last question.  I uploaded the map file using the paperclip.  Where does the file go?

  • A couple of other pointers

    There is commercial support available for GCC.  One of the ways they sometimes provide extra value is by providing libraries more optimal for embedded work rather than the default libraries.  Rowley is one such (In addition it also provides an IDE that is AFAIK not based on the behemoth that is eclipse).

    If you are more of a roll-your-own developer you can also take a look at newlib which can be smaller than the desktop version

    Leaving out the stdio items makes a big difference. Functions like memory and string support are generally reasonable.

     

    Robert

  • Robert Adsett said:
    If you are more of a roll-your-own developer you can also take a look at newlib which can be smaller than the desktop version

    The arm-none-eabi-4_7-2013q3 compiler installed by CCSv6 only includes the pre-compiled GNU libraries, and not the source for the libraries.

    Downloading the source package from https://launchpad.net/gcc-arm-embedded/4.7/4.7-2013-q3-update shows that that libraries are based upon the Red Hat “newlib” version. i.e. believe that the libraries are already an embedded version rather than the desktop version.