Teensy/Arduino Library compilation errors

339 views Asked by At

I'm currently writing a library application for my Teensy using the Arduino IDE and so far, it has been straight forward enough to do. I have however come across a bit of an odd compilation error that I just can't seem to get my head around. My library includes the well known IRRemote Library in order for me to create what is almost a wrapper library in order to be more specific into the way I need to interact with the IR Remote library. The issue I'm having is with one of the IR Remote library functions:

void  sendRaw(const unsigned int buf[],unsigned int len, unsigned int); 

Although this may seem like a straight forward function to use, the issue i have is with the first argument to the function. I have tried all various ways to pass something to this function paramater but whatever I do, it simply will not compile. Currently i have set a variable

unsigned int bufferToSend[5] = {1,2,3,4,5}; // data is just for example purposes

when i try to call

sendRaw(bufferToSend, 5, 38); // Values are just for example purposes

i get a compiler error of

undefined reference to `IRsend::sendRaw(unsigned int const*, unsigned int, unsigned int)'

Interestingly, if i call the same function directly from inside the Arduino .ino file rather than via my library call, the code compiles and runs perfectly well. Am I missing something blatantly obvious?

1

There are 1 answers

1
CBrown92 On

With the help of 'Some programmer dude', I was able to resolve this issue. As it was quite rightfully pointed out, I wasn't actually linking against the external library from within my library. having worked with library linking previously, I know this is absolutely fundamental, however with Arduino and its nature, it compiles libraries that are linked against "on-the-go" when you include from the Arduino script and therefore i fell victim to thinking it would be the same in a custom library. I came across a very good write-up of my exact problem below that provides an excellent explanation to some of the Arduino "smoke and mirrors" magic and how to get round the issue I've faced here.

Advanced Arduino – Including Multiple Libraries In Your Project