Using Arduino Libraries with AVR-G++
Asked Answered
E

2

7

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)'
Ethben answered 17/8, 2011 at 22:45 Comment(0)
U
3

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.

Unhealthy answered 5/8, 2012 at 8:23 Comment(0)
S
2

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.

Sola answered 17/8, 2011 at 23:5 Comment(1)
Those links are dead, but this CMake Arduino project still exists: github.com/tttapa/Arduino-AVR-CMake/blob/master/README.mdSciential

© 2022 - 2024 — McMap. All rights reserved.