【问题标题】:how to start arduino in windows with cl compiler如何使用 cl 编译器在 windows 中启动 arduino
【发布时间】:2015-05-03 19:43:23
【问题描述】:

我刚刚为 arduino 购买了一个工具包,在我拿到包之前,我想开始探索这些库。似乎arduino依赖于它自己的IDE。在arduino的文件夹里面,有一个main.cpp,所以我想用clcompiler visual studio 2013编译这个文件。不幸的是没有readme文件。我不知道应该添加和使用哪些库。在main.cpp

#include <Arduino.h>

//Declared weak in Arduino.h to allow user redefinitions.
int atexit(void (*func)()) { return 0; }

// Weak empty variant initialization function.
// May be redefined by variant files.
void initVariant() __attribute__((weak));
void initVariant() { }

int main(void)
{
    init();

    initVariant();

#if defined(USBCON)
    USBDevice.attach();
#endif

    setup();

    for (;;) {
        loop();
        if (serialEventRun) serialEventRun();
    }

    return 0;
}

当我运行时(即在同一个文件夹中)

cl /EHsc main.cpp /Fetest.exe

即使Arduino.h 在同一个文件夹中,我也收到此错误

main.cpp(20) : fatal error C1083: Cannot open include file: 'Arduino.h': No such file or directory

我的问题是是否可以在不使用带有cl 编译器的 IDE 的情况下运行这些库?

【问题讨论】:

  • @DavidGrayson,.exe 目录下的文件。问题是尖括号。将此 &lt;Arduino.h&gt; 更改为 "Arduino.h" but it throws another errors \stdlib.h(114):错误 C3646:“属性”:未知覆盖说明符. I'm not sure if arduino is compatible with cl` 编译器。

标签: c++ visual-studio arduino cl


【解决方案1】:

可能不会。 Arduino 库通常用于在 AVR 等嵌入式处理器上运行。如果他们访问处理器的任何硬件,那么您将很难编辑这些库以使它们在 cl 编译器下在 Windows 上运行。

另一个问题是这些库是用 gcc 编译的,它具有 cl 没有的功能。

但是,如果您能说出您正在使用什么工具包和库,而不是含糊其辞,这将有所帮助。

【讨论】:

  • 如果可能的话,我计划使用 arduino 的所有库。我想至少从简单的项目开始,比如 LED 闪烁。我见过一些人在 Youtube 中使用视觉工作室。用MinGW怎么样?
  • 您将需要某种 AVR 或 Arduino 仿真框架来执行此操作,您不能只使用 cl 编译库。 LED 通常可以通过 Arduino 函数pinModedigitalWrite 打开。 Arduino IDE 附带了那些实际写入 AVR 硬件寄存器的函数的实现。如果您想看到屏幕上的虚拟 LED 亮起,那么您必须获得这些功能的替代实现。我不知道在哪里可以找到这样的工具,但这些 YouTube 视频及其说明可能会有所帮助。
  • 尝试在 Arduino Stack Exchange 网站上提问。这是一个与您类似的问题:arduino.stackexchange.com/questions/61/…
【解决方案2】:

我什至不确定 Arduino 是否与 cl 编译器完全兼容,也许您更喜欢使用 Visual Micro 而不是这个来为 Visual Studio 中的 Arduino 编程。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-15
    相关资源
    最近更新 更多