Trouble with any sketch that uses a library

It has been a couple of years since i was last on here or played around with an Arduino project. I recently broke out my Nove, downloaded Arduino 1.0 and went about familiarizing myself with everything. The project i'm working on will need a Keypad and LCD display. So i've been relearning how to connect my HD44780 display and uploading one of the example sketches from the LiquidCrystal Library. But when i go to compile the sketch Arduino 1.0 spits out a bunch of errors.

In file included from HelloWorld.cpp:39:
C:\Documents and Settings\Michael\My Documents\arduino-1.0\libraries\LiquidCrystal/LiquidCrystal.h:82: error: conflicting return type specified for 'virtual void LiquidCrystal::write(uint8_t)'
C:\Documents and Settings\Michael\My Documents\arduino-1.0\hardware\arduino\cores\arduino/Print.h:48: error:   overriding 'virtual size_t Print::write(uint8_t)'
HelloWorld:97: error: redefinition of 'LiquidCrystal lcd'
HelloWorld:41: error: 'LiquidCrystal lcd' previously declared here
HelloWorld.cpp: In function 'void setup()':
HelloWorld:99: error: redefinition of 'void setup()'
HelloWorld:43: error: 'void setup()' previously defined here
HelloWorld.cpp: In function 'void loop()':
HelloWorld:106: error: redefinition of 'void loop()'
HelloWorld:50: error: 'void loop()' previously defined here

I've even tried sketches i made a couple of years ago that use this library and get the same problem. It seems any sketch that involves a library is giving me problems with compiling. Any help would be much appreciated.

You might be running afoul of a problem with the way the IDE converts your sketch into a .cpp file. Add this as the first line of your sketch:

char junk;

It will force the IDE to put the headers in front of everything else.

Pete

Thanks but that didn't change anything.

This is happening with any sketch i use that uses a library. Be it a sketch i made myself or one of the default example sketches that come with the various libraries.

Can you post the sketch ?

What is the path to your libraries?

The Sketch i first tried to compile and upload is the Hello World example sketch from the LiquidCrystal Library. Nothing was changed in the sketch i just tried to compile it and it came back with all the errors i posted in the OP. I then tried other example sketches from the other Libraries that came with Arduino 1.0 and had the same issue. The Library folder has not been removed from the Arduino 1.0 folder. There may be some older libraries in there that i moved over from my Arduino .8 folder but all the library examples i've tried are from recent and up to date libraries.

I'll try a complete wipe of Arduino from my system and reinstall it when i get home. This has been very odd since its only those sketches that use libraries that won't compile. Others example sketches such as Blink load just fine.

I've done a fresh install of Arduino 1.0 and all the built in library examples work fine now. But i just added the Keypad library and none of the examples it has will compile. I get this list of errors.

CustomKeypad:48: error: redefinition of 'const byte ROWS'
CustomKeypad:11: error: 'const byte ROWS' previously defined here
CustomKeypad:49: error: redefinition of 'const byte COLS'
CustomKeypad:12: error: 'const byte COLS' previously defined here
CustomKeypad:51: error: redefinition of 'char hexaKeys [4][4]'
CustomKeypad:14: error: 'char hexaKeys [4][4]' previously defined here
CustomKeypad:57: error: redefinition of 'byte rowPins [4]'
CustomKeypad:20: error: 'byte rowPins [4]' previously defined here
CustomKeypad:58: error: redefinition of 'byte colPins [4]'
CustomKeypad:21: error: 'byte colPins [4]' previously defined here
CustomKeypad.cpp: In function 'void setup()':
CustomKeypad:63: error: redefinition of 'void setup()'
CustomKeypad:26: error: 'void setup()' previously defined here
CustomKeypad.cpp: In function 'void loop()':
CustomKeypad:67: error: redefinition of 'void loop()'
CustomKeypad:30: error: 'void loop()' previously defined here

Why won't any new libraries work?

But i just added the Keypad library and none of the examples it has will compile.

Which keypad library? Where did you put it? What OS?

Why won't any new libraries work?

Must just be you. I have very few troubles.

I seem to recall that the upgrade to IDE 1.0 meant changing an include file in libraries
I think it was <wire.h> becomes <Arduino.h>
but the memory is going lala lala lala

I think it was <wire.h> becomes <Arduino.h>

WProgram.h becomes Arduino.h.

that's the fellah!

It's this keypad library. http://www.arduino.cc/playground/Code/Keypad

On win XP. It in the Arduino 1.0/library folder as it should be.

So the WProgram.h to Arduino.h needs to be changed in Keypad.h right?

Thanks for the help!

hmm I just downloaded that the change is in Keypad.h but

it already has

// Arduino versioning.
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"    // for digitalRead, digitalWrite, etc
#else
#include "WProgram.h"
#endif

do you have an old copy of the library?

On win XP. It in the Arduino 1.0/library folder as it should be.

Wrong! Wrong! Wrong!

The only things that belong in the Arduino 1.0\libraries folder are the official libraries.

Downloaded libraries are supposed to be stored in the same folder you store your sketches is, in a libraries folder. In my case, I store my sketches in
C:\Users\pjs9486\Documents\Arduino
so I have
C:\Users\pjs9486\Documents\Arduino\libraries
where I put libraries I download (this is on Win7).

Ok i'm at work right now and on a win7 system. I just downloaded the IDE and the Keypad Library. I put the library in the C:\Users\pilcherm\Documents\Arduino\libraries folder as it should be.

I have the current version of the library and see that it has the Arduino.h in it. But i still get the same errors. I've been trying this on 2 different PC now and will try a 3rd here in about an hour and a half. There must be something overly obvious i'm missing here. Or maybe there is a better keypad library i could be using.

I downloaded the library for Ladyada's motor shield to see if its just the Keypad library. Well the motor shield examples give me no problems. It's like the IDE doesn't like setting a const byte.

Sitting in front of another Win7 PC and just installed the 1.0 IDE and downloaded the Keypad Library. I'm still getting the same problems. What am i missing here?

Has the last 2 years really made me forget this much about Arduino?

FWIW, I've just downloaded the library onto my MacBook, with IDE 1.0, and I get the same issue with the HelloKeypad sketch. Never had a problem with any other libraries.

EDIT: Just noticed, there are two tabs in the sketch, with the same code in. If I save the sketch with a new name, and delete the second tab, it's fine.

All the keypad example sketches have the same issue. Is it because there is both an ino and a pde copy in each directory? I renamed the pde to .scrap, and re-opened the HelloKeypad sketch. Only one tab, no problem compiling.

Wow i didn't notice that before. I'll bet its creating a tab for the older IDEs and one for IDE 1.0. Somehow having 2 tabs may be messing with the compiler. Neither tab will compile.

I saved the sketch under a different name and it compiles as it should. Now i can go home tonight and get everything wired up and see if its even going to work for me. I not sure if there will be any problem if the Arduino is using a keypad that belongs to another device that is still using it. I'm trying to use the Arduino to pick up button presses on my Casio Keyboard so the Arduino can display which Tone or Beat i'm using on the Keyboard. Just hope there isn't any conflict due to the voltage on the buttons. But i'll save that for another thread once i've done some testing of my own.

Thanks all.

Just hope there isn’t any conflict due to the voltage on the buttons. But i’ll save that for another thread once i’ve done some testing of my own.

I think you can count on the fact that there WILL be problems. The keypad library applies voltage to each row, and reads whether any switch on each column is pressed. If there is another voltage source, the keypad library will not return correct results.

i have the same problem ! transfered the keypad library to where my sketches are saved ! i opened the examples from file - sketchbook - libraries - keypad - examples - CustomKeypad

but still when i compile the sketch i get this problems

CustomKeypad:48: error: redefinition of 'const byte ROWS' CustomKeypad:11: error: 'const byte ROWS' previously defined here CustomKeypad:49: error: redefinition of 'const byte COLS' CustomKeypad:12: error: 'const byte COLS' previously defined here CustomKeypad:51: error: redefinition of 'char hexaKeys [4][4]' CustomKeypad:14: error: 'char hexaKeys [4][4]' previously defined here CustomKeypad:57: error: redefinition of 'byte rowPins [4]' CustomKeypad:20: error: 'byte rowPins [4]' previously defined here CustomKeypad:58: error: redefinition of 'byte colPins [4]' CustomKeypad:21: error: 'byte colPins [4]' previously defined here CustomKeypad.cpp: In function 'void setup()': CustomKeypad:63: error: redefinition of 'void setup()' CustomKeypad:26: error: 'void setup()' previously defined here CustomKeypad.cpp: In function 'void loop()': CustomKeypad:67: error: redefinition of 'void loop()' CustomKeypad:30: error: 'void loop()' previously defined here

i am runing on windos 7 ! Has anyone have an idea why ?