External library inclusion

library

#1

Hello,

I'm creating an axo objet which uses a library from arduino which manage InfraRed.
I tried to include it :
- locally (same folder as my .axo file)
- via library inclusion in preferences

I got the same error :

fatal error: IRremote.h: No such file or directory

What is the right way to include external libraries ?

Thanks for your help.

Here is my code :

<objdefs>
   <obj.normal
         id="irinstrument"
         uuid="oiejoi21684jerfjeoirjf5"
         sha="">
      <upgradeSha></upgradeSha>
      <sDescription>Some description</sDescription>
      <author>Emilie Zawadzki</author>
      <license>LicenceType</license>
      <helpPatch>helpfile.axh</helpPatch>

      <inlets/>
      <outlets>
         <int32 name="code" description="hex code of the clicked button"/>
      </outlets>
      <displays/>
      <params/>
      <attribs>
         <spinner name="delay" MinValue="1" MaxValue="10000" DefaultValue="60"/>
         <combo name="channel">
            <MenuEntries>
               <string>PA0 (ADC1_IN0)</string>
               <string>PA1 (ADC1_IN1)</string>
               <string>PA2 (ADC1_IN2)</string>
               <string>PA3 (ADC1_IN3)</string>
               <string>PA4 (ADC1_IN4)</string>
               <string>PA5 (ADC1_IN5)</string>
               <string>PA6 (ADC1_IN6)</string>
               <string>PA7 (ADC1_IN7)</string>
               <string>PB0 (ADC1_IN8)</string>
               <string>PB1 (ADC1_IN9)</string>
               <string>PC0 (ADC1_IN10)</string>
               <string>PC1 (ADC1_IN11)</string>
               <string>PC2 (ADC1_IN12)</string>
               <string>PC3 (ADC1_IN13)</string>
               <string>PC4 (ADC1_IN14)</string>
            </MenuEntries>
            <CEntries>
               <string>0</string>
               <string>1</string>
               <string>2</string>
               <string>3</string>
               <string>4</string>
               <string>5</string>
               <string>6</string>
               <string>7</string>
               <string>8</string>
               <string>9</string>
               <string>10</string>
               <string>11</string>
               <string>12</string>
               <string>13</string>
               <string>14</string>
            </CEntries>
         </combo>
      </attribs>
      <includes>
        <include>IRremote.h</include>
      </includes>

      <code.declaration><![CDATA[#include "IRremote.h"
      int RECV_PIN = attr_channel;
      IRrecv irrecv(RECV_PIN);
      decode_results results;
      ]]></code.declaration>

      <code.init><![CDATA[irrecv.enableIRIn();]]></code.init>

      <code.krate><![CDATA[if(irrecv.decode(&results)) {
        outlet_code = results.value;
        irrecv.resume(); // Receive the next value}]]></code.krate>
      <code.srate><![CDATA[
      ]]></code.srate>

      <!--<code.midihander><![CDATA[
      ]]></code.midihander>-->
   </obj.normal>
</objdefs>

#2

Did you try a leading ./ ?
Check the axoloti-contrib repo. Various people have added include files to their objects.
E.g.

      <includes>
         <include>./tiar_bank_pwr.h</include>
      </includes>

Perhaps the bigger question is how to hack in the functions you will most likely need to link to.


#3

Hello deadsy,

Yes, tried :

<includes>
    <include>./IRremote.h</include>
</includes>

with :

<code.declaration><![CDATA[#include "./IRremote.h"....

For this test, all my headers files where located locally, at the same level as my .axo file.
I don't understand what is going on.


#4

Okay, I make it worked by putting IRremote.h in "build" folder. It makes no sense.


#5

there is an include section in the object editor.

however, there is no mechanism in the current release to link an additional library.
if you need to do that, you are going to need to hack the build scripts (for now)

the next release has a concept of modules, which are separate compile/link units, so this will 'solve' this issue.


#6

Actually, I've solved the issue by adding my header file in "build" folder. This is not logical but work.
As I'm trying to use some arduino sensors example code which needs external libraries, I'm really interresting in this new version. Do you have a release date ?


#7

It makes no sense.

It's not mysterious. It's just a bit arbitrary.

For example:

      <includes>
         <include>./goom.h</include>
      </includes>

Results in the following generated code at the top of xpatch.cpp:

#include "/home/jasonh/work/axo/work/objects/goom.h"

Your line:

<code.declaration><![CDATA[#include "IRremote.h"

Adds the file as a second, and probably surplus include. It needs to be in ./build since that is in the include path for the patch compilation. So... drop the c-code #include and just use the XML style specification.