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

several - undefined reference errors when using make

I am trying to add ADC to my program per the nordic examples on GitHub. Using GCC, SDK12, nrf51. These are the errors I am getting: (sorry for the formatting of this - code and block quote did not seem to work):

Linking target: _build/nrf51822_xxac.out _build/nrf51822_xxac_main.c.o: In function timer1_handler': C:\SDK12\examples\TEST\TEST 1590\51822\s130\Make/../../../main.c:178: undefined reference tonrf_drv_adc_sample' _build/nrf51822_xxac_main.c.o: In function adc_event_handler': C:\SDK12\examples\TEST\TEST 1590\51822\s130\Make/../../../main.c:138: undefined reference tonrf_drv_adc_buffer_convert' _build/nrf51822_xxac_main.c.o: In function adc_config': C:\SDK12\examples\TEST\TEST 1590\51822\s130\Make/../../../main.c:150: undefined reference tonrf_drv_adc_init' C:\SDK12\examples\TEST\TEST 1590\51822\s130\Make/../../../main.c:156: undefined reference to nrf_drv_adc_channel_enable' C:\SDK12\examples\TEST\TEST 1590\51822\s130\Make/../../../main.c:161: undefined reference tonrf_drv_adc_channel_enable' C:\SDK12\examples\TEST\TEST 1590\51822\s130\Make/../../../main.c:166: undefined reference to nrf_drv_adc_channel_enable' _build/nrf51822_xxac_main.c.o: In functionmain': C:\SDK12\examples\TEST\TEST 1590\51822\s130\Make/../../../main.c:670: undefined reference to `nrf_drv_adc_buffer_convert' collect2.exe: error: ld returned 1 exit status make: *** [_build/nrf51822_xxac.out] Error 1

What am I missing?

Parents
  • Looks like you forgot to include the source or library file(s) that provide the nrf_drv_adc_... functions.

  • Thank you awneil and Kristin. I did have an include for nrf_drv_adc.h when I was getting that error. I changed that from the header file to the c file (now include was: nrf_drv_adc.c) and it worked. If I add both the header and the c file, it fails with more errors. The examples I followed had the header file only included and they compiled fine. I dug a little deeper and compared the MAKE files and the one that was failing had this line missing:

    	  $(SDK_ROOT)/components/drivers_nrf/adc/nrf_drv_adc.c \
    

    Once I added that, everything worked fine. Thank you again both of you for taking the time to help me! I feel stupid having to ask this question but that is how you learn I guess...

Reply
  • Thank you awneil and Kristin. I did have an include for nrf_drv_adc.h when I was getting that error. I changed that from the header file to the c file (now include was: nrf_drv_adc.c) and it worked. If I add both the header and the c file, it fails with more errors. The examples I followed had the header file only included and they compiled fine. I dug a little deeper and compared the MAKE files and the one that was failing had this line missing:

    	  $(SDK_ROOT)/components/drivers_nrf/adc/nrf_drv_adc.c \
    

    Once I added that, everything worked fine. Thank you again both of you for taking the time to help me! I feel stupid having to ask this question but that is how you learn I guess...

Children
No Data
Related