This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Undefined reference to `nrf_log_init(unsigned int (*)())' with TWI and C++

HEllo

I am using the example TWI_sensor_pca10040 with a main.cpp, and I see that there is some sort of error with the logging that I cannot point out. I get this error

Linking twi_sensor_pca10040.elf Output/twi_sensor_pca10040 nrf52832_xxaa/Obj/main.o: In function main': undefined reference tonrf_log_init(unsigned int (*)())'

The line causing the error is APP_ERROR_CHECK(NRF_LOG_INIT(NULL)); when calling NRF_LOG_INIT()

THe logging is not enabled #define TWI_CONFIG_LOG_ENABLED 0 #define NRF_LOG_DEFAULT_LEVEL 0

If I enable it I get errors

  Compiling ‘nrf_drv_twi.c’
    nrf_drv_twi.c
    expected statement before ')' token
    in definition of macro 'NRF_LOG_DEBUG'
    in expansion of macro 'EVT_TO_STR'
    expected statement before ')' token
    in definition of macro 'NRF_LOG_DEBUG'
    in expansion of macro 'EVT_TO_STR'
    expected statement before ')' token
    in expansion of macro 'NRF_LOG_DEBUG'
    expected statement before ')' token
    in definition of macro 'NRF_LOG_DEBUG'
    in expansion of macro 'EVT_TO_STR'
    expected statement before ')' token
    in definition of macro 'NRF_LOG_DEBUG'
    in expansion of macro 'EVT_TO_STR'
    expected statement before ')' token
    in expansion of macro 'NRF_LOG_DEBUG'
    expected statement before ')' token
    in definition of macro 'NRF_LOG_DEBUG'
    in expansion of macro 'EVT_TO_STR'
    expected statement before ')' token
    in definition of macro 'NRF_LOG_DEBUG'
    in expansion of macro 'EVT_TO_STR'
    expected statement before ')' token
    in expansion of macro 'NRF_LOG_DEBUG'
  C:/Projects/nRF5_SDK_12.2.0/examples/peripheral/twi_sensor - a/pca10040/blank/arm4/../config/sdk_config.h (21.03.2017 12:33:19) is newer than Output/twi_sensor_pca10040 nrf52832_xxaa/Obj/nrf_drv_uart.o (21.03.2017 12:31:54).
  Compiling ‘nrf_drv_uart.c’
  C:/Projects/nRF5_SDK_12.2.0/examples/peripheral/twi_sensor - a/pca10040/blank/arm4/../config/sdk_config.h (21.03.2017 12:33:19) is newer than Output/twi_sensor_pca10040 nrf52832_xxaa/Obj/app_error.o (21.03.2017 12:32:02).
  C:/Projects/nRF5_SDK_12.2.0/examples/peripheral/twi_sensor - a/pca10040/blank/arm4/../config/sdk_config.h (21.03.2017 12:33:19) is newer than Output/twi_sensor_pca10040 nrf52832_xxaa/Obj/app_error_weak.o (21.03.2017 12:31:54).
  Compiling ‘app_error_weak.c’
  Compiling ‘app_error.c’
Build failed

If I disable the logging then everything goes fine since there is not logging, #define NRF_LOG_ENABLED 0 so, I wonder , what's happening?

thanks

Related