Library loading errors...

Hi,

I’m having a problem with loading a simple sketch. It is spitting out that it can’t find some library files.

In file included from sketch_jan29a.cpp:1:
C:\Users\Dad\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h:37:22: error: WProgram.h: No such file or directory
In file included from sketch_jan29a.cpp:1:
C:\Users\Dad\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h:44: error: 'byte' does not name a type
C:\Users\Dad\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h:46: error: 'byte' has not been declared
C:\Users\Dad\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h:46: error: 'byte' has not been declared
C:\Users\Dad\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h:47: error: expected ';' before '(' token
C:\Users\Dad\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h:48: error: 'byte' has not been declared
C:\Users\Dad\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h:49: error: 'byte' does not name a type
C:\Users\Dad\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h:50: error: expected ';' before '(' token
C:\Users\Dad\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h:51: error: 'byte' does not name a type
C:\Users\Dad\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h:52: error: 'boolean' does not name a type
C:\Users\Dad\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h:53: error: 'boolean' does not name a type
C:\Users\Dad\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h:56: error: 'byte' does not name a type
C:\Users\Dad\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h:57: error: 'byte' does not name a type
C:\Users\Dad\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h:58: error: 'byte' does not name a type
C:\Users\Dad\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h:61: error: 'uint8_t' has not been declared
C:\Users\Dad\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h:62: error: 'uint8_t' does not name a type
C:\Users\Dad\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h:63: error: 'uint8_t' does not name a type
C:\Users\Dad\Documents\Arduino\libraries\USB_Host_Shield/Max3421e.h: In static member function 'static void MAX3421E::spi_init()':

This is only the first 1/3 of the error log. I have searched around online and a few have said they have corrected this with making sure the libraries are copied to the location of the sketch, and I have done that. I have deleted and reinstalled all the components over again (Arduino and the ADK libraries). I have tried this on a new machine that has never even seen an Arduino board before, same problem, so i’m sure this is an error somewhere on my end. Looking for some help PLEASE,

My Sketch:

#include <Max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>
 
AndroidAccessory acc("Manufacturer",
                                     "Model",
                                     "Description",
                                     "1.0",
                                     "http://yoursite.com",
                                     "0000000012345678");
void setup()
{
  Serial.begin(115200);
  acc.powerOn();
}
 
void loop()
{
  byte msg[1]; // one byte
  int value=10; // value to send,we'll increment and decrement this variable
  if (acc.isConnected())
  {
    // is connected
    while(value>0)
    {
      // count down
      msg[0] = value;
      acc.write(msg, 1);
      delay(1000);
      value-=1;
    }
 
    while(value<=10)
    {
      // count up
      msg[0] = value;
      acc.write(msg, 1);
      delay(1000);
      value+=1;
    }
  }
}

Thanks,
Andrew

Are you using Arduino IDE 1.0?

Once again WProgram.h is now named Arduino.h as of version 1.0 of the IDE.

Yes, I am using Arduino 1.0. I see the "Arduino.h" file in the hardware directory and everything, there's no WProgram.h anywhere eitehr.

Downloaded directly from Arduino:

Still trying to figure out what is wrong.

-Andrew

Still trying to figure out what is wrong.

You've been told what is wrong. The WProgram.h file was renamed to Arduino.h. You can either change the library that has not been upgraded to 1.0, or go back to an older version of the IDE.

Ahhh... sorry for my miss-understanding. I'm seeing the calling for WProgram inside the individual libraries that are erroring.

Thanks for your help

This is a common problem with external libraries. There is a simple fix that you can do to resolve this issue for all the libraries, though it means you need to add a file to the standard Arduino package:

Create a new file with the following content:

#ifndef __WPROGRAM_H__
#define __WPROGRAM_H__

#include "Platform.h"

#endif // __WPROGRAM_H__

Place the file in the hardware/arduino/cores/arduino folder.

Eventually, the library maintainers will have updated their libraries to work with 1.0, but until then, this resolves the problem.

Neglected to mention that the file should be saved as WProgram.h

This WProgram.h thing is becoming a plague... I guess it'll still pop-up 10 years from now ]:slight_smile:

a simple search for files named *.h containting text "WProgram.h" will give you a list of headers referencing same, edit each to use Arduino.h, also any referenced to WConstants.h also reflect to Arduino.h.

mromani - Yes, I imagine it will, as long as there are newbe's, like me. But every time it does pop up I learn something new. I found the WProgram.h vs. Arduino.h change in the release notes, but WHERE IS IT WRITTEN that you also need to setup a fix for WConstants.h?

I offer my appologies to all 'oldtimers' for all the seemingly stupid questions, especially mine..., but that IS part of how we learn. And the answers may be, and probablly are, out there for us to find, but it isn't always very intuitive or easy to find them. SEARCH ain't the greatest thing since sliced salami.

I fear I have been misunderstood... When I wrote my comment (and that smiley) I was not thinking "those newbies will keep asking this thing for eternity", but rather "until the docs are fixed, we'll see this question asked" and also "thanks to the huge success of arduino, there are so many libraries out there, that before all of them switch from wprogram.h to arduino.h it's going to take years."

I apologize for being (unintentionally) unkind to newbies... (I'm a total newbie myself except for some c and c++ programming knowledge).

SEARCH ain’t the greatest thing since sliced salami.

I agree. Knowing what to search for is as important to getting good answers as having good data to search.

On the other hand, if one comes to the forum and says “Hey, I have a problem, help me out”, one will get a much different response than if one comes in and says “Hey, I have a problem. I’ve tried searching for an answer, and I either get no matches or I get conflicting answers or I don’t understand the answers I get or how they apply. Help me out”.

Far too many people make no effort to find answers before posting. Look at the Installation and Troubleshooting forum. The same 6 questions are asked over and over, because people don’t search.

And they generally don't read the release notes on the page they download the software from. Although in this case, the OP did.