Pages: [1]   Go Down
Author Topic: Getting libraries to work  (Read 1041 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just installed arduino-0004 and am having trouble getting custom libraries to work.  I wrote one of my own and was having trouble, so I went back to basics and tried to use the Matrix library that's included with the package.  Here is the code:


#include <Matrix.h>

void setup()
{
    
}

void loop()
{
   delay(1000);
}


Notice that I am not doing anything witht the library in the code... I just include it.  When I compile, I get this:

lib\targets\libraries\Matrix\Matrix.o: In function `Matrix::write(unsigned char, unsigned char, Sprite)':

/cygdrive/c/Documents and Settings/davin/My Documents/electronics/arduino-0004/lib\targets\libraries\Matrix\Matrix.cpp:202: undefined reference to `Sprite::read(unsigned char, unsigned char) const'


/cygdrive/c/Documents and Settings/davin/My Documents/electronics/arduino-0004/lib\targets\libraries\Matrix\Matrix.cpp:201: undefined reference to `Sprite::width() const'


/cygdrive/c/Documents and Settings/davin/My Documents/electronics/arduino-0004/lib\targets\libraries\Matrix\Matrix.cpp:200: undefined reference to `Sprite::height() const'


It seems like OTHER libraries (in this case Sprite) that the library uses are not getting included in the linker script.  I get a similar effect with my custom library, but in this case I can call the class constructor of the class that I am defining in my cpp file, but then when I try to actually call a method within that class it gives me the same "undefined reference to..." error.

Help?  Thanks!


Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You're right about the Matrix case: you also need to include the Sprite library as we don't yet have a system for automatically handling library dependencies.

The issue with your custom library sounds like it might be different.  Can you post the code (or a simpler version with the same problem)?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hm... i'm still in the process of figuring it out, but it seems like when the library is edited, the .o file needs to be deleted manually before the sketch is compiled in Ardunio.  When I manually delete it, the compile work OK.  Does the IDE compile the libraries only on launch or does it recompile them every time the sketch is compiled?
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Every time a sketch is compiled, if you've deleted the library's .o file.
Logged

Pages: [1]   Go Up
Jump to: