简体   繁体   English

使用带有AVR-G ++的Arduino库

[英]Using Arduino Libraries with AVR-G++

Is there a simple way to use libraries intended for the Arduino IDE with the C and assembly code I write for AVR-G++/AVR-GCC? 是否有一种简单的方法可以使用用于Arduino IDE的库以及我为AVR-G ++ / AVR-GCC编写的C和汇编代码?

I'm trying to use the Adafruit Wave Shield library , but simply including the header and cpp files don't do much good. 我正在尝试使用Adafruit Wave Shield库 ,但只是包含头文件和cpp文件并没有太大的帮助。 Can I compile it somehow and link it to my C code? 我可以以某种方式编译它并将其链接到我的C代码? Or perhaps just find a way to make it compile with my C code. 或者也许只是找到一种方法来使用我的C代码进行编译。

Currently, when I try to do something simple like: 目前,当我尝试做一些简单的事情时:

#include "WaveHC/WaveHC.h"    
SdReader card;
card.init();

I am greeted with: 我受到了欢迎:

70: undefined reference to `SdReader::init(unsigned char)'

I use this makefile to compile all my code for Arduino without using IDE. 我使用这个makefile来编译Arduino的所有代码而不使用IDE。 You can use both Arduino libs as well as user libs in this makefile. 您可以在此makefile中同时使用Arduino库和用户库。

Update : There is also a tutorial , which explains how to setup and use this makefile. 更新 :还有一个教程 ,介绍如何设置和使用此makefile。

You can build the Arduino code with CMake . 您可以使用CMake构建Arduino代码。 I have built largish Arduino projects without using the IDE this way. 我已经构建了大量的Arduino项目而没有使用IDE这种方式。 You can use whatever tools you want to build the Arduino code, it is just a C/C++ library. 您可以使用任何您想要构建Arduino代码的工具,它只是一个C / C ++库。 You mainly need to make sure you have all of the preprocessor settings right (F_CPU? Maybe some others). 您主要需要确保所有预处理器设置都正确(F_CPU?可能还有其他一些)。

Build using Cmake might help you. 使用Cmake构建可能对您有所帮助。 Basically, I would make a library file for the Arduino library, a library file for the shield library, and an EXE file for your code. 基本上,我会为Arduino库创建一个库文件,一个用于屏蔽库的库文件,以及一个代码的EXE文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM