【问题标题】:Undefined reference to __mulhi3 when using sprintf() - AVR GCC in Code::Blocks on Windows使用 sprintf() 时对 __mulhi3 的未定义引用 - Windows 上 Code::Blocks 中的 AVR GCC
【发布时间】:2019-02-26 16:21:26
【问题描述】:

我正在使用来自 Microchip (Atmel) 的 Code::Blocks 和 AVR-GCC 工具链。我正在尝试为Atmega32 编译程序。当我尝试编译使用sprintf() 函数的程序时,我得到“对__mulhi3 的未定义引用”。没有这个功能,我不会出错。在 Atmel Studio 或 Linux 下的 Code::Blocks 中编译的相同程序运行良好。

#include <avr/io.h>
#include <stdio.h>

int main(void)
{
    char buf[20];
    sprintf(buf, "Hello %d", 1);

    while(1);
    return 0;
}

【问题讨论】:

    标签: codeblocks avr undefined-reference avr-gcc


    【解决方案1】:

    问题是由 GNU GCC Compiler for AVR 的 Code::Blocks 的默认设置引起的 - C:/WinAVR/avr/lib 存在不必要的包含路径。你应该去

    设置 → 编译器... → AVR 的 GNU GCC 编译器 → 搜索目录 → 链接器

    并清除包含路径的列表。如果列表不为空,linker tries to link against wrong version of library.

    【讨论】:

      猜你喜欢
      • 2016-08-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-24
      • 2012-02-07
      • 1970-01-01
      • 2018-06-12
      • 2011-10-24
      相关资源
      最近更新 更多