arm gcc by default compiling its libc

时间:2016-02-12 22:08:11

标签: gcc arm embedded libc gnu-arm

I am trying to compile an SDK with the an embedded arm gcc compiler in cygwin. It is a makefile based SDK. My target is a cortex m3 device. My problem is, the SDK has a custom libc implementation for the target, and when I compile with the arm compiler (arm-none-eabi-gcc) it looks to pick up the gnu arm libc, not the SDK libc. This is resulting in a compilation error. I am positive the makefiles are correct (I copy and pasted the entire SDK from a computer where this was working). I no longer have access to that computer to try and verify / compare settings. I don't know how to prevent the arm gcc compiler from looking for its own implementation of the libc and instead point it to the correct implementation. Any help is greatly appreciated.

1 个答案:

答案 0 :(得分:0)

可能有两种解决方案:

  1. 创建特定于您的工具的环境 - GNU工具链使用许多环境变量来定义默认行为。对于自定义工具链,您需要设置所有必要的变量以覆盖系统默认值。
  2. 使用-nostdlib链接器选项并显式链接所需的库和C运行时启动代码,因此链接器命令行可能包含以下内容:

    -nostdlib -L ​​/ usr / myarmtools / gcc / lib -lc crt0.o

  3. 请注意-nostdlib禁止libc libstdc ++和crt0.o的默认链接,因此您必须为库提供搜索路径(-L),或者通过它们的完整路径和文件名显式链接它们并链接目标的C运行时对象代码。

    我使用选项2作为首选项,因为它可以在任何环境中使用。但是,如果您希望使用通用makefile来构建多个目标,则选项1可能很有用。