6
votes

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)'
2

2 Answers

3
votes

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.

2
votes

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.