title: Why do I have an undefined reference to _init in __libc_init_array?
body: <p>I'm attempting to build a simple project using Yagarto and Eclipse for an ARM microcontroller platform. In my startup code, I have this (which I believe is fairly standard and uninteresting):</p>
  
  <pre><code>void Reset_Handler(void)
  {
    /* Initialize data and bss */
    __Init_Data();
  
    /* Call CTORS of static objects */
    __libc_init_array();
  
    /* Call the application's entry point.*/
    main();
  
    while(1) { ; }
  }
  </code></pre>
  
  <p>Unless I comment out the call to <code>__libc_init_array()</code>, I get the following error from the linker:</p>
  
  <pre><code>arm-none-eabi-g++ -nostartfiles -mthumb -mcpu=cortex-m4 -TC:/Users/mark/workspace/stm32_cpp_test/STM32F40x_1024k_192k_flash.ld -gc-sections -Wl,-Map=test_rom.map,--cref,--no-warn-mismatch -o stm32_cpp_test "system\\syscalls.o" "system\\startup_stm32f4xx.o" "system\\mini_cpp.o" "system\\cmsis\\system_stm32f4xx.o" main.o 
  d:/utils/yagarto/bin/../lib/gcc/arm-none-eabi/4.7.2/../../../../arm-none-eabi/lib/thumb/v7m\libg.a(lib_a-init.o): In function `__libc_init_array':
  C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\thumb\v7m\newlib\libc\misc/../../../../../../../newlib-1.20.0/newlib/libc/misc/init.c:37: undefined reference to `_init'
  collect2.exe: error: ld returned 1 exit status
  </code></pre>
  
  <p>Why am I getting this "undefined reference" error? What am I missing? I assume there's some linker flag that I'm missing, but I can't for the life of me figure out what.</p>