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.

TM4C123 Using UArtprintf getting errors

Other Parts Discussed in Thread: TM4C123GH6PM

I've just started programming and I wanted to print a simple message to the terminal using Uartprintf, found in util/uartstdio.h.  I'm getting and error:

unresolved symbol __error__, first referenced in ./util/uartstdio.obj lab12 C/C++ Problem 

I have added a folder to the project called util in which I coped and pasted uartstdio.h and uartstdio.c.  I do not know where the problem is coming from.  Any help much appreciated.  

  • Hello Brittany

    What are the defines that you are using during the build? Also can you please share the compilation log?
  • Britanny,
    Copying the Tivaware files into your project ain't the best solution.
    Download and install the full library into a know directory on your computer, which does not need to be related to your project's location.
    From there, there are a few solutions to tell your project that you will "use a file located somewhere"...
    I personally like to do:
    1- My Tivaware files are where TI suggests them to be, which can be something like "C:\ti\TivaWare213156"
    2- On my IDE (and I'm assuming you are using CCS) preferences, I define one global variable which will be good for all projects in it: on Preferences/CodeComposerStudio/Build/Variables, I add TIVA_ROOT, type Path, with the value of the directory above. That's NOT inside the project.
    3- Now, inside your project's properties, there are a couple of things to inform it to use those files:
    -- CCSBuild/ARMCompiler/IncludeOptions has an entry that points to the global variable, which is "${TIVA_ROOT}"
    -- CCSBuild/ARMLinker/FileSearchPath has an entry that points to the location of the compiled library, which is "${TIVA_ROOT}/driverlib/ccs/Debug/driverlib.lib"
    4- Finally, it is time to include the files in your project... Simply go to the main header (main.h?), and, for example, to use UARTprintf, you need #include "utils/uartstdio.h"
    Sounds complicated, but there won't be any ways to use library files without a few "housekeeping" steps... The above strategy lets you, for example, easily use a new library when it becomes available, by simply changing the global variable on CCS. And it ensures you that you are using only one working and reliable version of a library file. If you have two copies of anything in your projects, trust me, chances are that one of those will be wrong/outdated in less than two days...
    Back in the days when I had to figure this out "or simply repeat what the master had said", every time I needed a new project things were very painful... So the above became standard practice among my colleagues.
    Happy developing,
    Bruno
  • Hi Amit,

    These are my defines :
    #include <stdbool.h>
    #include <stdint.h>
    #include "inc/hw_memmap.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/pwm.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"

    and I'm not sure where to find the compilation log?
  • Hi Bruno,

    I have been following the Tiva C Series lab and I have one setup similar to your TIVA_ROOT pointing to my libraries in C:\ti\TivaWare_C_Series-2.1.3.156 which has all my libraries including utils. Do you mind if I pasted my code here?
  • Hello Brittany

    In CCS there is a Console log which shows the results of the compilation.
  • Thank you, here is the complete log.

    **** Build of configuration Debug for project testingUART ****

    "C:\\ti\\ccsv6\\utils\\bin\\gmake" -k all
    'Building target: testingUART.out'
    'Invoking: ARM Linker'
    "C:/ti/ccsv6/tools/compiler/ti-cgt-arm_16.9.0.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --define=ccs="ccs" --define=PART_TM4C123GH6PM -g --gcc --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi -z -m"testingUART.map" --heap_size=0 --stack_size=512 -i"C:/ti/ccsv6/tools/compiler/ti-cgt-arm_16.9.0.LTS/lib" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-arm_16.9.0.LTS/include" --reread_libs --diag_wrap=off --display_error_number --warn_sections --xml_link_info="testingUART_linkInfo.xml" --rom_model -o "testingUART.out" "./main.obj" "./tm4c123gh6pm_startup_ccs.obj" "C:/ti/TivaWare_C_Series-2.1.3.156/driverlib/ccs/Debug/driverlib.lib" "../tm4c123gh6pm.cmd" -llibc.a
    <Linking>

    undefined first referenced
    symbol in file
    --------- ----------------
    UARTStdioConfig ./main.obj
    UARTprintf ./main.obj

    error #10234-D: unresolved symbols remain
    error #10010: errors encountered during linking; "testingUART.out" not built

    >> Compilation failure
    makefile:142: recipe for target 'testingUART.out' failed
    gmake: *** [testingUART.out] Error 1
    gmake: Target 'all' not remade because of errors.

    **** Build Finished ****
  • Hello! I rechecked all my paths, and while I did have the Path and Build Variables set up as a path to my libraries, I decided to link the header and source file directly to my project.

    I right-clicked my project >Add Files >Navigated to the folder with the files(ex: C:\ti\TivaWare_C_Series-2.1.3.156\utils) >chose both uartstio.h and uartstdio.c and linked it to my project. It works now. If this isn't the proper way, please let me know!
  • Hello Brittany,

    The compilation/linker error was because of the missing the files in the compile order. What you have done is the correct method.
  • Brittany Ko said:
    If this isn't the proper way, please let me know!

    Hi Brittany,

    I try to avoid including each library file separately. It would be a duplicated effort, I believe the only "mandatory" place to include a file in c should be in the header #include directive... If it is wrong or not, might be a matter of preference.

    This is a typical directory structure inside one project here:

    And to make such work, these are the project settings:

    A typical #include list on your main header file would be:

    #include <stdint.h>
    #include <stdio.h>
    #include <stdlib.h>
    
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "inc/hw_ints.h"
    
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    
    #include "utils/uartstdio.h"

    Hope this is useful - and if that ain't a good practice, I'd ask the more experienced colleagues to please advise.

    Cheers

    Bruno