构建 Arduino 软件时如何包含目录
How to include directories when building Arduino software
我正在做一个小的 Arduino 项目。官方的ArduinoIDE实在是太烂了,所以我改用Netbeans来开发。这是我的生成文件:
OBJDIR = ../build
ARDUINO_DIR = /usr/share/arduino
TARGET = main
MCU = atmega328p
F_CPU = 16000000
ARDUINO_PORT = /dev/ttyACM0
AVRDUDE_ARD_PROGRAMMER = arduino
AVRDUDE_ARD_BAUDRATE = 115200
include /usr/share/arduino/Arduino.mk
我想使用位于/usr/local/include/myproject
的一些header,所以在源代码中我添加:
#include "myproject/someheader.h"
现在,当我尝试编译项目时,我收到一条错误消息
fatal error: myproject/someheader.h: No such file or directory
如何在构建项目时包含 /usr/local/include 目录?通常,我会添加
INC=-I/usr/local/include
但这不起作用,我想我需要以其他方式添加 header 文件?
最终从 arduino 目录添加一个符号 link 到我的库位置:
ln -s /usr/local/include /usr/share/arduino/libraries/Custom
然后,我将 "Custom" "library" 添加到 arduino makefile 中,我的 makefile 现在是:
OBJDIR = ../build
ARDUINO_DIR = /usr/share/arduino
TARGET = main
MCU = atmega328p
F_CPU = 16000000
ARDUINO_PORT = /dev/ttyACM0
AVRDUDE_ARD_PROGRAMMER = arduino
AVRDUDE_ARD_BAUDRATE = 115200
ARDUINO_LIBS = Custom # <---- !
include /usr/share/arduino/Arduino.mk
构建过程似乎现在获取了我的头文件
我正在做一个小的 Arduino 项目。官方的ArduinoIDE实在是太烂了,所以我改用Netbeans来开发。这是我的生成文件:
OBJDIR = ../build
ARDUINO_DIR = /usr/share/arduino
TARGET = main
MCU = atmega328p
F_CPU = 16000000
ARDUINO_PORT = /dev/ttyACM0
AVRDUDE_ARD_PROGRAMMER = arduino
AVRDUDE_ARD_BAUDRATE = 115200
include /usr/share/arduino/Arduino.mk
我想使用位于/usr/local/include/myproject
的一些header,所以在源代码中我添加:
#include "myproject/someheader.h"
现在,当我尝试编译项目时,我收到一条错误消息
fatal error: myproject/someheader.h: No such file or directory
如何在构建项目时包含 /usr/local/include 目录?通常,我会添加
INC=-I/usr/local/include
但这不起作用,我想我需要以其他方式添加 header 文件?
最终从 arduino 目录添加一个符号 link 到我的库位置:
ln -s /usr/local/include /usr/share/arduino/libraries/Custom
然后,我将 "Custom" "library" 添加到 arduino makefile 中,我的 makefile 现在是:
OBJDIR = ../build
ARDUINO_DIR = /usr/share/arduino
TARGET = main
MCU = atmega328p
F_CPU = 16000000
ARDUINO_PORT = /dev/ttyACM0
AVRDUDE_ARD_PROGRAMMER = arduino
AVRDUDE_ARD_BAUDRATE = 115200
ARDUINO_LIBS = Custom # <---- !
include /usr/share/arduino/Arduino.mk
构建过程似乎现在获取了我的头文件