Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

I'm trying to use the Adafruit Wave Shield library, but simply including the header and cpp files don't do much good. Can I compile it somehow and link it to my C code? Or perhaps just find a way to make it compile with my C code.

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)'
like image 807
Anon Avatar asked Aug 17 '11 22:08

Anon


2 Answers

I use this makefile to compile all my code for Arduino without using IDE. You can use both Arduino libs as well as user libs in this makefile.

Update: There is also a tutorial, which explains how to setup and use this makefile.

like image 158
Sudar Avatar answered Oct 05 '22 12:10

Sudar


You can build the Arduino code with CMake. I have built largish Arduino projects without using the IDE this way. You can use whatever tools you want to build the Arduino code, it is just a C/C++ library. You mainly need to make sure you have all of the preprocessor settings right (F_CPU? Maybe some others).

Build using Cmake might help you. 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.

like image 34
rounin Avatar answered Oct 05 '22 14:10

rounin