<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>hello, <br>
    </p>
    <p>I am trying to include a static library that contains the startup
      code for ARM processor to my  CMake project for cross compilation.
      <br>
    </p>
    <p> I included the linker script and added it to the executable.
      Flags and include files are properly set in the CMake build
      output. The path to the library is also correctly seen. <br>
    </p>
    <p>The linker fails on the startup code:</p>
    <p><br>
    </p>
    <pre><code>Scanning dependencies of target testApp
[ 50%] Building CXX object CMakeFiles/testApp.dir/src/main.c.obj
[100%] Linking CXX executable testApp
/opt/gcc-arm-none-eabi-7-2017-q4-major/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard/libc.a(lib_a-exit.o): In function `exit':
exit.c:(.text.exit+0x1c): undefined reference to `_exit'
/opt/gcc-arm-none-eabi-7-2017-q4-major/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard/libc.a(lib_a-fini.o): In function `__libc_fini_array':
fini.c:(.text.__libc_fini_array+0x2c): undefined reference to `_fini'
/opt/gcc-arm-none-eabi-7-2017-q4-major/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard/libc.a(lib_a-init.o): In function `__libc_init_array':
init.c:(.text.__libc_init_array+0x38): undefined reference to `_init'
collect2: error: ld returned 1 exit status


Here is my CMakeLists file:

<b>cmake_minimum_required(VERSION 3.5.1)</b><b>
</b><b>project (hello-world)</b><b>
</b><b>
</b><b>set(SOURCE_FILES src/main.c)</b><b>
</b><b>
</b><b>set (LINKER_SCRIPT linker_script.ld)</b><b>
</b><b>
</b><b>add_executable(${TARGET_NAME} ${SOURCE_FILES})</b><b>
</b><b>
</b><b>set_target_properties( ${TARGET_NAME} PROPERTIES LINK_DEPENDS ${LINKER_SCRIPT})</b><b>
</b><b>
</b><b>set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-build-id=none -Wl,-T ${LINKER_SCRIPT} " CACHE STRING "" FORCE )</b><b>
</b><b>
</b><b>set(COMMON_FLAGS "${COMMON_FLAGS} -march=armv7-a")</b><b>
</b><b>set(COMMON_FLAGS "${COMMON_FLAGS} -mfpu=vfpv3")</b><b>
</b><b>set(COMMON_FLAGS "${COMMON_FLAGS} -mfloat-abi=hard")</b><b>
</b><b>set(COMMON_FLAGS "${COMMON_FLAGS} -Wall")</b><b>
</b><b>set(COMMON_FLAGS "${COMMON_FLAGS} -O0")</b><b>
</b><b>set(COMMON_FLAGS "${COMMON_FLAGS} -nostartfiles")</b><b>
</b><b>set(COMMON_FLAGS "${COMMON_FLAGS} -fmessage-length=0")</b><b>
</b><b>set(COMMON_FLAGS "${COMMON_FLAGS} -fno-exceptions")</b><b>
</b><b>set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}")</b><b>
</b><b>set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}")</b><b>
</b><b>
</b><b>include_directories( inc )</b><b>
</b><b>
</b><b>find_library(LIB_C NAMES libc PATHS "lib" )</b><b>
</b><b>
</b><b>target_link_libraries(${TARGET_NAME} ${LIB_C})</b><b>
</b>

How can I solve this problem? The only dependency here is the library itself...

Thank you in advance for any response. 
</code></pre>
  </body>
</html>