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.

When I using GNU v4.7.3 compiler to compile the project, the following errors appear after adding printf() function in the C file.

The stdio.h file has been added to the project,the following errors appear when compiling the project which have printf() function.Looking forward to your reply.

  • The only GCC ARM compiler supported on this forum is the Linaro one which ships with CCS.  Based on what I can see, you are using some other ARM compiler.  So, I'll answer in terms how of the Linaro GCC compiler does things, and hope that your GCC compiler does things in a similar manner.

    Some examples for how to build code can be found in compiler install root/share/gcc-arm-none-eabi/samples/src .  Take the minimum example for instance.  It contains a link command file gcc.ld with these two lines ...

    INCLUDE "mem.ld"
    INCLUDE "sections-nokeep.ld"
    

    The interesting one is sections-nokeep.ld.  It can be found in compiler install root/share/gcc-arm-none-eabi/samples/ldscripts.  Inspect it to see that it defines several symbols which comments say "code can use without definition".  One of those symbols is "end", which is the one causing your link to fail.  The link is failing because no definition of "end" is supplied.

    I recommend you find the examples for your GCC compiler, and track down the linker script file it uses to define, among other things, the symbol "end".

    Thanks and regards,

    -George

  • Thanks very much for your reply.

    The compiler I use is included in CCS.The sections-nokeep.ld file is as follows.3718.sections-nokeep.rar

    When I did not add printf() function,it compile without error. After adding printf() function,it appeared the above errors. How the printf() function affect the compilation?And how can I to correct it?

    Thanks and regards.

  • The symbol "end" is defined in sections-nokeep.ld.  Are you sure this file is used during the link?

    Thanks and regards,

    -George

  • How can I konw whether the link has used the sections-nokeep.ld file or not?Looking forward to your reply.

    Thanks and regards.

  • Look at the linker invocation line in the Console window and piece together what it is doing.  In the minimum example I referred to earlier, you can see the linker invocation line use "-T gcc.ld", then inside that gcc.ld file, it refers to sections-nokeep.ld.  Try to find something similar to that.

    Thanks and regards,

    -George

  • The Console window displays the following abnormal information.

    h:/ti/ccsv5/tools/compiler/gcc-arm-none-eabi-4_7-2012q4/bin/../lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/lib\librdimon.a(rdimon-syscalls.o): In function `_sbrk':
    syscalls.c:(.text._sbrk+0x50): undefined reference to `end'
    collect2.exe: error: ld returned 1 exit status
    gmake: *** [platform_am335x.out] Error 1
    gmake: Target `all' not remade because of errors.

    What should I do?

    Thanks and regards.

  • You aren't using linker command files at all.  That's surprising.  I presume you started with an example of some sort.  Where did you get that example from?  With that information, I can probably refer you to the forum most likely to answer your question.

    Thanks and regards,

    -George

  • I'm surprised you think I didn't use the linker command file. I am using.lds file, when you using the GNU compiler you must use the.lds link file as the linker file. Did you ever used the GNU Compiler? Can you give me an example of GNU compiler?

  • The last screen shot you show includes a box for "Linker Command Files (-T, --script)", and this box is blank.  From that I conclude you not using any linker command files.

    I doubt I can answer your questions.  That's why I have asked you for the source of your example.  Once I know that, I suspect I can direct you to the forum which is familiar with that example, and is more likely to be helpful.

    Thanks and regards,

    -George