AnsweredAssumed Answered

JN-AN-1217: Why can't I build with my own source files?

Question asked by Jonathan Witthoeft on Jul 11, 2019
Latest reply on Jul 12, 2019 by Jonathan Witthoeft

OS:                Windows 7
SDK:             JN-SW-4170 (Build Number 1840)
Application:   JN-AN-1217 (Version 1005)

 

When Adding a source file/header file pair of any kind in the Router/Source directory and then including the header file and calling a function from that header file, I always get an "undefined reference to" that function and a "relocation truncated to fit" for that function's symbol. The following is the console output I get with the very simple test files I am using to isolate this problem.

 

*note- I realize this is an incremental build, however I get the same error on a clean build and figured this was shorter to include

Console:

16:56:36 **** Incremental Build of configuration Router, JN5169, DR1175 for project JN-AN-1217-Zigbee-3-0-Base-Device ****
make JENNIC_CHIP_FAMILY=JN516x JENNIC_CHIP=JN5169 ICODES=0 all
JENNIC_MAC is Mini MAC shim
JENNIC_MAC_PLATFORM is SOC
Building trace version ...
Linking /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/Router_NtagIcode_JN5169_DR1175.elf ...
/c/NXP/bstudio_nxp/sdk/Tools/ba-elf-ba2-r36379/bin/ba-elf-gcc -Wl,--gc-sections -Wl,-u_AppColdStart -Wl,-u_AppWarmStart -L/c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/NFC/Library -march=ba2 -mcpu=jn51xx -mredzone-size=4 -mbranch-cost=3 -fomit-frame-pointer -Os -fshort-enums -flto -nostartfiles -L/c/NXP/bstudio_nxp/sdk/JN-SW-4170/Chip/JN5169/Build -L/c/NXP/bstudio_nxp/sdk/JN-SW-4170/Chip/JN5169/Library -L/c/NXP/bstudio_nxp/sdk/JN-SW-4170/Platform/DK4/Library -L/c/NXP/bstudio_nxp/sdk/JN-SW-4170/Components/Library -Wl,--gc-sections -L/c/NXP/bstudio_nxp/sdk/JN-SW-4170/Stack/ZBPro/Build -Wl,--defsym=__stack_size=5000 -Wl,--defsym,__minimum_heap_size=2000 -L /c/NXP/bstudio_nxp/sdk/JN-SW-4170/Stack/ZCL/Build/ -TAppBuildZBPro.ld -o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/Router_NtagIcode_JN5169_DR1175.elf -Wl,--start-group /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/app_main.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/irq_JN516x.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/portasm_JN516x.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/port_JN516x.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/pdum_gen.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/pdum_apdu.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zps_gen.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/app_start.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/app_router_node.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/app_zcl_task.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/app_buttons.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/app_led_interface.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/app_ntag_icode.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/app_reporting.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/ZQueue.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/ZTimer.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/app_zps_link_keys.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/Alarms.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/AlarmsClientCommands.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/AlarmsCommandHandler.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/AlarmsServerCommands.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/AlarmsTableManager.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/AnalogInputBasic.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/AnalogOutputBasic.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/Basic.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/BasicClientCommands.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/BasicCommandHandler.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/BinaryInputBasic.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/BinaryOutputBasic.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/DeviceTemperatureConfiguration.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/Diagnostics.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/Groups.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/GroupsClientCommands.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/GroupsCommandHandler.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/GroupsServerCommands.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/GroupsTableManager.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/Identify.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/IdentifyClientCommands.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/IdentifyCommandHandler.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/IdentifyServerCommands.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/LevelControl.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/LevelControlClientCommands.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/LevelControlCommandHandler.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/MultistateInputBasic.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/MultistateOutputBasic.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/OOSC.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/OnOff.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/OnOffCommandHandler.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/OnOffCommands.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/PollControl.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/PollControlClientCommands.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/PollControlCommandHandler.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/PollControlServerCommands.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/PowerConfiguration.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/PowerProfile.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/PowerProfileClientCommands.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/PowerProfileCommandHandler.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/PowerProfileServerCommands.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/Scenes.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/ScenesClientCommands.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/ScenesClusterManagement.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/ScenesCommandHandler.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/ScenesServerCommands.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/ScenesTableManager.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/TC.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/Time.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/base_device.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/mains_power_outlet.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/on_off_output.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/plug_control.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/remote_control.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/simple_sensor.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/dlist.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_CustomCommandReceive.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_CustomCommandSend.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_PDUbufferReadWrite.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_PDUbufferReadWriteString.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_WriteAttributesRequestHandle.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_WriteAttributesRequestSend.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_WriteAttributesResponseHandle.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_attribute.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_buffer.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_clusterCommand.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_command.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_common.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_configureReportingCommandHandle.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_configureReportingCommandSend.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_configureReportingResponseHandle.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_defaultResponse.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_discoverAttributesExtendedRequestHandle.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_discoverAttributesExtendedRequestSend.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_discoverAttributesExtendedResponseHandle.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_discoverAttributesRequestHandle.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_discoverAttributesRequestSend.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_discoverAttributesResponseHandle.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_discoverCommandsRequestHandle.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_discoverCommandsRequestSend.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_discoverCommandsResponseHandle.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_event.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_heap.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_library_options.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_readAttributesRequestHandle.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_readAttributesRequestSend.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_readAttributesResponseHandle.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_readReportingConfigurationCommandHandle.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_readReportingConfigurationCommandSend.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_readReportingConfigurationResponseHandle.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_reportManager.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_reportMaths.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_reportScheduler.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_reportStringHandling.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_reportStructure.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_search.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_timer.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/zcl_transmit.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/bdb_fr.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/bdb_start.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/bdb_state_machine.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/appZpsBeaconHandler.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/appZdpExtraction.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/bdb_ns.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/bdb_nf.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/bdb_fb_common.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/bdb_fb_target.o /c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/bdb_DeviceCommissioning.o -lZPSMAC_Mini_SOC_JN516x -lPWRM_JN516x -lZPSTSV_JN516x -lAES_SW_JN516x -lPDUM_JN516x -lZPSAPL_JN516x -lRandom_JN516x -lPDM_EEPROM_NO_RTOS_JN516x -lDBG_JN516x -lZPSNWK_JN516x -lNTAG_JN516x -lMiniMac_JN5169 -lMiniMacShim_JN516x -lMMAC_JN5169 -lJPT_JN5169 -lAes_JN516x -lHardwareApi_JN5169 -lMicroSpecific_JN516x -lBoot_JN516x -lBoardLib_JN516x -lJPT_JN5169 -lm -Wl,--end-group -Wl,-Map,Router_NtagIcode_JN5169_DR1175.map
C:\Users\jonw\AppData\Local\Temp\cc64QFC2.ltrans0.ltrans.o: In function `AppColdStart':
cc64QFC2.ltrans0.o:(.text+0x3ed): undefined reference to `test_fn'
cc64QFC2.ltrans0.o:(.text+0x3ed): relocation truncated to fit: R_BA_18_PCREL against undefined symbol `test_fn'
collect2.exe: error: ld returned 1 exit status
make: *** [/c/NXP/bstudio_nxp/workspace/JN-AN-1217-Zigbee-3-0-Base-Device/Router/Build/Router_NtagIcode_JN5169_DR1175.elf] Error 1

 

test.c:

#include <stdint.h>

int test_fn(){
   int h=0
   for(int i=0;i<10;i++)
   h++;
   return h;
}


test.h:

int test_fn();

 

app_start.c (init function only):

PRIVATE void APP_vInitialise(void)
{
   /* Initialise Power Manager even on non-sleeping nodes as it allows the
   * device to doze when in the idle task */
   PWRM_vInit(E_AHI_SLEEP_OSCON_RAMON);


   test_fn();

 

   /* Initialise the Persistent Data Manager */
   PDM_eInitialise(63);

 

   /* Initialise Protocol Data Unit Manager */
   PDUM_vInit();

 

   ZPS_vExtendedStatusSetCallback(vfExtendedStatusCallBack);

 

   /* Initialise application */
   APP_vInitialiseRouter();
}

Outcomes