# CMakeLists.txt : Link options not working properly

**URL:** https://discourse.cmake.org/t/cmakelists-txt-link-options-not-working-properly/489
**Category:** Code
**Tags:** comp:ti
**Created:** [January 13, 2020, 10:14pm UTC](https://discourse.cmake.org/t/cmakelists-txt-link-options-not-working-properly/489 "2020-01-13T22:14:28Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![sramnath](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@sramnath](https://discourse.cmake.org/u/sramnath)
#### Post date: [January 13, 2020, 10:14pm UTC](https://discourse.cmake.org/t/cmakelists-txt-link-options-not-working-properly/489/1 "2020-01-13T22:14:28Z")

</div>

Hello,

I am using the TI-CGT compiler and have been successful in getting all my  
source files to compile. However, I am unable to get the link command to  
successfully link, and I have crafted a manual link command which I have to  
then manually enter into the terminal once the build compiles all the files  
and fails at the link stage.  
I derived the link command from Code Composer Studio and took guidance for  
what libraries are missing. However when I tried to add this to the  
target\_link\_libraries in CMake, that didn’t work.

Here is my manual link command:

> “/Applications/ti\_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm\_18.12.2.LTS/bin/armcl”  
> -mv7M4 --code\_state=16 --float\_support=FPv4SPD16 -me  
> –define=DeviceFamily\_CC13X2 -g --diag\_warning=225 --diag\_warning=255  
> –diag\_wrap=off --display\_error\_number --gen\_func\_subsections=on -z  
> -m"lwipthreads\_CC1352P1\_LAUNCHXL\_tirtos\_ccs.map"  
> -i"/Applications/ti\_ccs9/simplelink\_cc13x2\_26x2\_sdk\_3\_20\_00\_68/source"  
> -i"/Applications/ti\_ccs9/simplelink\_cc13x2\_26x2\_sdk\_3\_20\_00\_68/kernel/tirtos/packages"  
> -i"/Applications/ti\_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm\_18.12.2.LTS/lib"  
> –diag\_wrap=off --display\_error\_number --warn\_sections  
> –xml\_link\_info=“lwipthreads\_CC1352P1\_LAUNCHXL\_tirtos\_ccs\_linkInfo.xml”  
> –rom\_model --output\_file=“lwipthreads\_CC1352P1\_LAUNCHXL\_tirtos\_ccs.out”  
> “CMakeFiles/test.out.dir/main\_tirtos.c.obj”  
> “…/CC1352P1\_LAUNCHXL\_TIRTOS.cmd”  
> -l"/Applications/ti\_ccs9/simplelink\_cc13x2\_26x2\_sdk\_3\_20\_00\_68/source/ti/grlib/lib/ccs/m4f/grlib.a"  
> -lliblwipcontribapps.a -lliblwipboard.a -lliblwipcore.a  
> -lliblwipcontribporttirtos.a -l"ti/display/lib/display.aem4f"  
> -l"/Applications/ti\_ccs9/simplelink\_cc13x2\_26x2\_sdk\_3\_20\_00\_68/source/third\_party/spiffs/lib/ccs/m4f/spiffs\_cc26xx.a"  
> -l"/Applications/ti\_ccs9/simplelink\_cc13x2\_26x2\_sdk\_3\_20\_00\_68/source/ti/drivers/rf/lib/rf\_multiMode\_cc13x2.aem4f"  
> -l"/Applications/ti\_ccs9/simplelink\_cc13x2\_26x2\_sdk\_3\_20\_00\_68/source/ti/drivers/lib/drivers\_cc13x2.aem4f"  
> -l"/Applications/ti\_ccs9/simplelink\_cc13x2\_26x2\_sdk\_3\_20\_00\_68/kernel/tirtos/packages/ti/dpl/lib/dpl\_cc13x2.aem4f"  
> -l"…/linker.cmd"  
> -l"/Applications/ti\_ccs9/simplelink\_cc13x2\_26x2\_sdk\_3\_20\_00\_68/source/ti/devices/cc13x2\_cc26x2/driverlib/bin/ccs/driverlib.lib"  
> -llibc.a

Here, liblwipcore.a, liblwipcontribporttirtos.a, liblwipboard.a,  
liblwipcontribapps.a, are libraries that I have made using my  
CMakeLists.txt. The rest are standard libraries coming from TI’s SDK.

The other thing is that I am unable to add the  
…/CC1352P1\_LAUNCHXL\_TIRTOS.cmd in the CMakeLists.txt the way that I need it  
in the linker command that I added above. This file has some information  
about sections for .data, .code, .bss, flash memory partitions and the  
system memory map etc. so it is definitely required by the CC1352P1 board to  
be able to run this on the board.

Here is what I have in CMakeLists.txt for the link step :

> set( cc1352p1\_libs  
> ${TIRTOS\_SDK}/source/ti/display/lib/display.aem4f  
> ${TIRTOS\_SDK}/source/ti/grlib/lib/ccs/m4f/grlib.a  
> ${TIRTOS\_SDK}/source/third\_party/spiffs/lib/ccs/m4f/spiffs\_cc26xx.a  
> ${TIRTOS\_SDK}/source/ti/drivers/rf/lib/rf\_multiMode\_cc13x2.aem4f  
> ${TIRTOS\_SDK}/source/ti/drivers/lib/drivers\_cc13x2.aem4f  
> ${TIRTOS\_SDK}/kernel/tirtos/packages/ti/dpl/lib/dpl\_cc13x2.aem4f  
> ${TIRTOS\_SDK}/source/ti/devices/cc13x2\_cc26x2/driverlib/bin/ccs/driverlib.lib  
> /Applications/ti\_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm\_18.12.2.LTS/lib/rtsv7M4\_T\_le\_v4SPD16\_eabi.lib  
> ${LWIP\_DIR}/linker.cmd  
> )  
> set( cc1352p1\_lib\_dirs  
> ${TIRTOS\_SDK}/source/ti/display/lib  
> ${TIRTOS\_SDK}/source/ti/grlib/lib/ccs/m4f  
> ${TIRTOS\_SDK}/source/third\_party/spiffs/lib/ccs/m4f  
> ${TIRTOS\_SDK}/source/ti/drivers/rf/lib  
> ${TIRTOS\_SDK}/source/ti/drivers/lib  
> ${TIRTOS\_SDK}/kernel/tirtos/packages/ti/dpl/lib  
> ${TIRTOS\_SDK}/source/ti/devices/cc13x2\_cc26x2/driverlib/bin/ccs  
> ${TIRTOS\_SDK}/source/third\_party/fatfs/lib/ccs/m4  
> /Applications/ti\_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm\_18.12.2.LTS/lib  
> )  
> add\_link\_options(test.out …/CC1352P1\_LAUNCHXL\_TIRTOS.cmd)  
> target\_link\_libraries(test.out lwipcontribapps lwipboard  
> lwipcontribporttirtos lwipcontribexamples lwipcore  
> ${CMAKE\_COMPILER\_PATH}/lib/libc.a ${cc1352p1\_libs})  
> add\_definitions( ${LWIP\_COMPILE\_OPTIONS}) # ${LWIP\_BIOS\_OPTS} )

Here’s the error that I get when I say make:

> WARNING: invalid linker option  
> –warn\_sections–xml\_link\_info=gpiointerrupt\_CC1352P1\_LAUNCHXL\_tirtos\_ccs\_linkInfo.xml  
> (ignored)  
>   
> error #10056: symbol “free” redefined: first defined in  
> “/Users/sramnath/ccs\_workspaces/sdk\_3\_2/spiEthernet/tirtos\_builds\_CC1352P1\_L  
> AUNCHXL\_release\_ccs/Debug/configPkg/package/cfg/release\_pem4f.oem4f”;  
> redefined in  
> “/Applications/ti\_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm\_18.12.2.LTS/lib/rt  
> sv7M4\_T\_le\_v4SPD16\_eabi.lib\<memory.c.obj\>”  
> error #10056: symbol “realloc” redefined: first defined in  
> “/Users/sramnath/ccs\_workspaces/sdk\_3\_2/spiEthernet/tirtos\_builds\_CC1352P1\_L  
> AUNCHXL\_release\_ccs/Debug/configPkg/package/cfg/release\_pem4f.oem4f”;  
> redefined in  
> “/Applications/ti\_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm\_18.12.2.LTS/lib/rt  
> sv7M4\_T\_le\_v4SPD16\_eabi.lib\<memory.c.obj\>”  
> error #10056: symbol “memalign” redefined: first defined in  
> “/Users/sramnath/ccs\_workspaces/sdk\_3\_2/spiEthernet/tirtos\_builds\_CC1352P1\_L  
> AUNCHXL\_release\_ccs/Debug/configPkg/package/cfg/release\_pem4f.oem4f”;  
> redefined in  
> “/Applications/ti\_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm\_18.12.2.LTS/lib/rt  
> sv7M4\_T\_le\_v4SPD16\_eabi.lib\<memory.c.obj\>”  
> error #10056: symbol “calloc” redefined: first defined in  
> “/Users/sramnath/ccs\_workspaces/sdk\_3\_2/spiEthernet/tirtos\_builds\_CC1352P1\_L  
> AUNCHXL\_release\_ccs/Debug/configPkg/package/cfg/release\_pem4f.oem4f”;  
> redefined in  
> “/Applications/ti\_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm\_18.12.2.LTS/lib/rt  
> sv7M4\_T\_le\_v4SPD16\_eabi.lib\<memory.c.obj\>”  
> error #10056: symbol “malloc” redefined: first defined in  
> “/Users/sramnath/ccs\_workspaces/sdk\_3\_2/spiEthernet/tirtos\_builds\_CC1352P1\_L  
> AUNCHXL\_release\_ccs/Debug/configPkg/package/cfg/release\_pem4f.oem4f”;  
> redefined in  
> “/Applications/ti\_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm\_18.12.2.LTS/lib/rt  
> sv7M4\_T\_le\_v4SPD16\_eabi.lib\<memory.c.obj\>”  
> “…/linker.cmd”, line 646: warning #10096-D: specified address lies outside  
> memory map  
> error #10264: DEFAULT memory range overlaps existing memory range RAM  
> undefined first referenced  
> symbol in file --------- ----------------  
> \_\_aeabi\_cdcmple  
> /Users/sramnath/ccs\_workspaces/sdk\_3\_2/spiEthernet/tirtos\_builds\_CC1352P1\_LAUNCHXL\_release\_ccs/Debug/configPkg/package/cfg/release\_pem4f.oem4f  
> \_\_aeabi\_cdrcmple  
> /Users/sramnath/ccs\_workspaces/sdk\_3\_2/spiEthernet/tirtos\_builds\_CC1352P1\_LAUNCHXL\_release\_ccs/Debug/configPkg/package/cfg/release\_pem4f.oem4f  
> \_\_aeabi\_d2iz  
> /Users/sramnath/ccs\_workspaces/sdk\_3\_2/spiEthernet/tirtos\_builds\_CC1352P1\_LAUNCHXL\_release\_ccs/Debug/configPkg/package/cfg/release\_pem4f.oem4f  
> \_\_aeabi\_d2uiz  
> /Users/sramnath/ccs\_workspaces/sdk\_3\_2/spiEthernet/tirtos\_builds\_CC1352P1\_LAUNCHXL\_release\_ccs/Debug/configPkg/package/cfg/release\_pem4f.oem4f  
> \_\_aeabi\_dmul  
> /Users/sramnath/ccs\_workspaces/sdk\_3\_2/spiEthernet/tirtos\_builds\_CC1352P1\_LAUNCHXL\_release\_ccs/Debug/configPkg/package/cfg/release\_pem4f.oem4f  
> \_\_aeabi\_dsub  
> /Users/sramnath/ccs\_workspaces/sdk\_3\_2/spiEthernet/tirtos\_builds\_CC1352P1\_LAUNCHXL\_release\_ccs/Debug/configPkg/package/cfg/release\_pem4f.oem4f  
> \_\_aeabi\_f2d  
> /Users/sramnath/ccs\_workspaces/sdk\_3\_2/spiEthernet/tirtos\_builds\_CC1352P1\_LAUNCHXL\_release\_ccs/Debug/configPkg/package/cfg/release\_pem4f.oem4f  
> \_\_aeabi\_i2d  
> /Users/sramnath/ccs\_workspaces/sdk\_3\_2/spiEthernet/tirtos\_builds\_CC1352P1\_LAUNCHXL\_release\_ccs/Debug/configPkg/package/cfg/release\_pem4f.oem4f  
> \_\_aeabi\_uidivmod  
> /Users/sramnath/ccs\_workspaces/sdk\_3\_2/spiEthernet/tirtos\_builds\_CC1352P1\_LAUNCHXL\_release\_ccs/src/sysbios/rom\_sysbios.aem4f\<rom\_sysbios.obj\>  
> **primary\_heap\_end**  
> /Users/sramnath/ccs\_workspaces/sdk\_3\_2/spiEthernet/tirtos\_builds\_CC1352P1\_LAUNCHXL\_release\_ccs/Debug/configPkg/package/cfg/release\_pem4f.oem4f  
> **primary\_heap\_start**  
> /Users/sramnath/ccs\_workspaces/sdk\_3\_2/spiEthernet/tirtos\_builds\_CC1352P1\_LAUNCHXL\_release\_ccs/Debug/configPkg/package/cfg/release\_pem4f.oem4f  
> sys\_init liblwipcore.a\<init.c.obj\>  
> sys\_mbox\_trypost liblwipcore.a\<tcpip.c.obj\>  
> sys\_mbox\_valid liblwipcore.a\<tcpip.c.obj\>  
> sys\_now liblwipcore.a\<netif.c.obj\>  
> error #10234-D: unresolved symbols remain  
> error #10010: errors encountered during linking; “test.out” not built

These errors are all resolved when I manually enter the above linker  
command.

Please help me out with the link step of the CMake command.
