Go Down

Topic: problem with creating a library (Read 914 times) previous topic - next topic


Oct 27, 2012, 10:54 pm Last Edit: Oct 27, 2012, 11:21 pm by HagaiOfer Reason: 1
i've tried  to learn hot to create a new library , i did it all just as explained buy the site and still i had an error showing

this is the error
sketch_oct27a.cpp.o: In function `setup':
C:\Users\hagai\AppData\Local\Temp\build8272096594347651372.tmp/sketch_oct27a.cpp:8: undefined reference to `Led::Led(int)'

this is my code

Code: [Select]

#ifndef Led_h
#define Led_h

#include "Arduino.h"

class Led
    Led (int pin);
    void on();
    void off();
    int _pin;


Code: [Select]

#include "Arduino.h"
#include "Led.h"
Led::Led(int pin)
  pinMode(pin, OUTPUT);
  _pin = pin;

void Led::on()
  digitalWrite(_pin, HIGH);

void Led::off()
  digitalWrite(_pin, LOW);

the sketch:
Code: [Select]

#include <Led.h>

Led led1(13);

void setup()
void loop()

thanks in advance


you might need to restart the IDE before it "sees" your new library.

Please use the # button to post code, it will give you [ code] tags to make it look better (easier to read).
you can modify your post to do so. JUst select the .h part and press # (above the smileys)

Can you post your sketch that uses the library too?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


Which version of the IDE are you using? I can pretty well guess that it is 1.0.1, which does not think that missing include files are a fatal error.


yes im using 1.0.1 , what i need to do to clear this error?


what i need to do to clear this error?

Shut down the IDE. Download the library. Install it in the right place. Restart the IDE. Keep your fingers crossed.

After the third or fourth time you install a library, the 5th step won't be required any more.



still not working.

Then uninstall 1.0.1 and install 1.0. Fuck that crappy version.


HagaiOfer, I just tried your library and it worked first time.
I use version 1.01 (and Windows Vista if that matters)

I'm afraid I don't understand which include files is missing


i just tried using both versions and still showing me the error , at least now i know its not something that i've done.
thanks again.


i just tried using both versions and still showing me the error

You need to post more details, then. For instance, what, exactly, is the source file for the Led class called? What is the header file called?


I quickly went into my Sketchbook/libraries folder and created a Led folder and inside that created a Led.h and a Led.cpp. I cut and pasted from the code here and it compiled fine with the sketch provided here.

I'm using 1.01 on Linux.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131