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.

AM263P4-Q1: How to create an image using only libraries

Part Number: AM263P4-Q1
Other Parts Discussed in Thread: SYSCONFIG

Environment:
CCS: 12.7.1 (ti-cgt-armllvm_3.2.2.LTS)
SDK: 9.2.0.56
SysConfig: 1.20.0

I compiled all application source files and archived all generated object files into a single library, including the main() function.
Library creation command:
"C:/ti/ccs1271/ccs/tools/compiler/ti-cgt-armllvm_3.2.2.LTS/bin/tiarmar.exe" rcs "my_application.lib" "./source/*.o" "./syscfg/*.o"

When I linked this library together with the SDK libraries, the linker reported the following errors (excerpt):
unresolved symbol __aeabi_assert, first referenced in C:/ti/mcu_plus_sdk_am263px_09_02_00_56/source/networking/enet/lib/lwipif-cpsw-freertos.am263px.r5f.ti-arm-clang.release.lib<pbufQ.obj>
unresolved symbol __aeabi_errno_addr, first referenced in C:/ti/mcu_plus_sdk_am263px_09_02_00_56/source/networking/lwip/lib/lwip-freertos.am263px.r5f.ti-arm-clang.release.lib<sockets.obj>
unresolved symbol __aeabi_llsl, first referenced in C:/ti/mcu_plus_sdk_am263px_09_02_00_56/source/kernel/freertos/lib/freertos.am263px.r5f.ti-arm-clang.release.lib<AddrTranslateP_32bit.obj>
unresolved symbol __aeabi_memclr4, first referenced in C:/ti/mcu_plus_sdk_am263px_09_02_00_56/source/kernel/freertos/lib/freertos.am263px.r5f.ti-arm-clang.release.lib<tasks.obj>
unresolved symbol __aeabi_memcpy, first referenced in C:/ti/mcu_plus_sdk_am263px_09_02_00_56/source/kernel/freertos/lib/freertos.am263px.r5f.ti-arm-clang.release.lib<queue.obj>
unresolved symbol __aeabi_memset4, first referenced in C:/ti/mcu_plus_sdk_am263px_09_02_00_56/source/kernel/freertos/lib/freertos.am263px.r5f.ti-arm-clang.release.lib<tasks.obj>
unresolved symbol __aeabi_uldivmod, first referenced in C:/ti/mcu_plus_sdk_am263px_09_02_00_56/source/kernel/freertos/lib/freertos.am263px.r5f.ti-arm-clang.release.lib<DebugP_log.obj>
unresolved symbol __TI_auto_init, first referenced in C:/ti/mcu_plus_sdk_am263px_09_02_00_56/source/kernel/freertos/lib/freertos.am263px.r5f.ti-arm-clang.release.lib<boot_armv7r_asm.obj>
unresolved symbol exit, first referenced in C:/ti/mcu_plus_sdk_am263px_09_02_00_56/source/kernel/freertos/lib/freertos.am263px.r5f.ti-arm-clang.release.lib<boot_armv7r_asm.obj>
unresolved symbol free, first referenced in C:/ti/mcu_plus_sdk_am263px_09_02_00_56/source/kernel/freertos/lib/freertos.am263px.r5f.ti-arm-clang.release.lib<heap_3.obj>
unresolved symbol malloc, first referenced in C:/ti/mcu_plus_sdk_am263px_09_02_00_56/source/kernel/freertos/lib/freertos.am263px.r5f.ti-arm-clang.release.lib<heap_3.obj>
unresolved symbol rand, first referenced in C:/ti/mcu_plus_sdk_am263px_09_02_00_56/source/networking/enet/lib/enet-cpsw.am263px.r5f.ti-arm-clang.release.lib<enet_apputils.obj>

There are no source files included in the build target.
The following libraries are specified in the Makefile for linking:
-Wl,-lfreertos.am263px.r5f.ti-arm-clang.release.lib \
-Wl,-ldrivers.am263px.r5f.ti-arm-clang.release.lib \
-Wl,-lenet-cpsw.am263px.r5f.ti-arm-clang.release.lib \
-Wl,-llwipif-cpsw-freertos.am263px.r5f.ti-arm-clang.release.lib \
-Wl,-llwip-freertos.am263px.r5f.ti-arm-clang.release.lib \
-Wl,-lboard.am263px.r5f.ti-arm-clang.release.lib \
-Wl,-llwip-contrib-freertos.am263px.r5f.ti-arm-clang.release.lib \
-Wl,-lmy_application.lib  # <- User-created library

Under the above conditions, linking succeeds if I add an arbitrary source file (for example, dummy.c) containing a simple function to the build.

My question is:
Is there any way to successfully link the application without adding any source files to the build target?
Since the main() function is already included in my_application.lib, I would expect the linker to be able to generate the executable using only libraries. Is there any linker option or recommended method for building an executable entirely from libraries when using TI Arm Clang and MCU+ SDK?

Requested response date: 2026/10/06

  • Hello Makoto,

    One way to do what you're asking is to create an unresolved symbol reference using the "-u<symbol>" option in your link command prior to specifying any of the libraries in the link command. The linker will then scan the specified libraries looking for a definition of the <symbol>specified in the -u linker option.

    For example, consider the following two source files:

    f1.c

    extern void print_hello(void);

    int main() {

      print_hello();

      return 0;

    }

    f2.c

    #include <stdio.h>

    void print_hello() {

      printf("hello\n");

    }

    We can create a library out of the above two source files, like so:

    %> tiarmclang -mcpu=cortex-m4 -c f1.c f2.c

    %> tiarmar rv mylib.a f1.o

    %> tiarmar rv mylib.a f2.o

    Then link the application using a "-umain" linker option as follows:

    %> tiarmclang -mcpu=cortex-m4 -Wl,-umain,mylib.a,-llnk.cmd,-ohello.out,-mhello.map

    To get an executable that when loaded and run will write "hello" to stdout:

    %> load470 -q hello.out
    hello

    I hope this helps.

    Incidentally, I would encourage you to use a more recent release of the tiarmclang compiler tools. Both the tiarmclang 5.1.1.LTS and 4.0.5.LTS compiler tools releases are currently available on ti.com (ARM-CGT-CLANG IDE, configuration, compiler or debugger | TI.com)

    Best Regards,

    Todd Snider