如何用makefile编译arduino核心库
How to compile arduino core library with makefile?
我想用makefile创建arduino核心库的库文件(a),最终也是其他库(SPI,…),但我无法让它工作!
这是我的makefile:
CC=avr-gcc
CPP=avr-g++
MCU=-mmcu=atmega328p
CPU_SPEED=-DF_CPU=16000000UL
CFLAGS=$(MCU) $(CPU_SPEED) -g2 -gstabs -Os -Wall
-ffunction-sections -fdata-sections -fno-exceptions
INCLUDE=-I./arduinoCORE
CFILES=$(wildcard ./arduinoCORE/*.c)
CPPFILES=$(wildcard ./arduinoCORE/*.cpp)
OBJ=$(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
default: $(OBJ)
avr-ar -r libarduinoUNO.a $^
%.o : %.c
$(CC) $< $(CFLAGS) -c -o $@
%.o : %.cpp
$(CPP) $< $(CFLAGS) -c -o $@
(所有头文件和源文件都在arduinoCORE;甚至pins_arduino.h)
在arduinoCORE上面的目录$ make
之后,我得到这个错误消息:
avr-g++ arduinoCORE/CDC.cpp -mmcu=atmega328p -DF_CPU=16000000UL -g2 -gstabs -Os -Wall -ffunction-sections -fdata-sections -fno-exceptions -c -o arduinoCORE/CDC.o
In file included from arduinoCORE/Print.h:27:0,
from arduinoCORE/Stream.h:26,
from arduinoCORE/HardwareSerial.h:28,
from arduinoCORE/Arduino.h:193,
from arduinoCORE/Platform.h:15,
from arduinoCORE/CDC.cpp:19:
arduinoCORE/Printable.h:23:17: fatal error: new.h: No such file or directory
#include <new.h>
^
compilation terminated.
make: *** [arduinoCORE/CDC.o] Error 1
问题是,new.h实际上是在arduinoCORE!有人知道怎么处理吗?
我有一个不同的错误与你的代码。它显示Arduino.h不存在。我在实际添加INCLUDE变量到CFLAGS和CPPFLAGS(您的已定义但未添加)后修复了它。
我还根据Arduino规范使用了CFLAGS和CPPFLAGS。代码是:
CC=avr-gcc
CPP=avr-g++
MCU=-mmcu=atmega328p
CPU_SPEED=-DF_CPU=16000000UL
INCLUDE=-I./
CFLAGS = -c -g -Os -w -ffunction-sections -fdata-sections -MMD $(MCU) $(CPU_SPEED) $(INCLUDE)
CPPFLAGS = -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD $(MCU) $(CPU_SPEED) $(INCLUDE)
CFILES=$(wildcard ./*.c)
CPPFILES=$(wildcard ./*.cpp)
OBJ=$(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
default: $(OBJ)
avr-ar rcs core.a $^
%.o : %.c
$(CC) $< $(CFLAGS) -c -o $@
%.o : %.cpp
$(CPP) $< $(CPPFLAGS) -c -o $@
成功创建存档(未测试,仅创建)。
相关文章:
- 在执行其他功能的同时播放动画(LED矩阵和Arduino/ESP8266)
- 如何找出GDB的SIGTRAP核心转储的根本原因
- C++映射分割错误(核心转储)
- 尽管测试成功,CppUnit测试核心仍被丢弃.为什么
- Arduino:for/while/if在void setup()或void loop()之前?——错误:之前需要不合格
- 在c++中初始化矩阵时出现分段错误(核心转储)
- C++核心准则 C35 对于接口类"A base class destructor should be either public and virtual, or protected and nonv
- MPI突然停止了对多个核心的操作
- 在多个核心中处理一个HTTP请求
- 人脸跟踪arduino代码的优化
- 如何处理来自核心指南检查器的关于gsl::at的静态分析警告
- vscode下的Arduino代码出现意外编译错误
- Arduino从Txt读取整数
- Arduino C++在构造函数中用参数声明对象数组
- 在c++中键入向量中的所有值后,得到分段错误(核心转储)
- C++ Boost::asio串行通信与Arduino无法写入
- Arduino millis() - millis() 怎么能等于 0 以外的任何东西?
- 在Arduino中将PWM通道命名为LEDC是否有特定原因
- 'val' Arduino 错误代码之前的预期'('
- 如何用makefile编译arduino核心库