Cannot Find WProgram.h (differant)

Ok so here is the deal,

Environment:
Compiled from Git Repo
Ubuntu x64

Last night I was successful at doing the blinking light tutorial using the sketch window. Now I want to create a C Library to do the Morse example. I am trying to do this in C instead of C++ but which I don't think should be that tough, but I am no expert. So I create the following in ./libraries/Morse

/*
  Morse.h - Library for flashing Morse code.
  Created by David A. Mellis, November 2, 2007.
  Released into the public domain.
*/
#ifndef Morse_h
#define Morse_h

#include <WProgram.h>

class Morse
{
  public:
    Morse(int pin);
    void dot();
    void dash();
  private:
    int _pin;
};

#endif

Morse.H

#include "WProgram.h"
#include "Morse.h"

Morse::Morse(int pin)
{
  pinMode(pin, OUTPUT);
  _pin = pin;
}

void Morse::dot()
{
  digitalWrite(_pin, HIGH);
  delay(250);
  digitalWrite(_pin, LOW);
  delay(250);  
}

void Morse::dash()
{
  digitalWrite(_pin, HIGH);
  delay(1000);
  digitalWrite(_pin, LOW);
  delay(250);
}

Morse.c

Now comes the tricky part, first if I try to do what I want (which is compile using gcc Morse) I get the following...

jackie@jackie-Latitude-E6410:~/Development/Code/Arduino/libraries/Morse$ gcc Morse.c 
Morse.c:1:22: fatal error: WProgram.h: No such file or directory
compilation terminated.

And if I use the sketch window I get the following...

     [exec] 
     [exec] 
     [exec] 
     [exec] 
     [exec] 
     [exec] 
     [exec] 
     [exec] 
     [exec] 
     [exec] 
     [exec] In file included from /home/jackie/Development/Code/Arduino/build/linux/work/libraries/Morse/Morse.c:2:
     [exec] /home/jackie/Development/Code/Arduino/build/linux/work/libraries/Morse/Morse.h:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Morse’
     [exec] /home/jackie/Development/Code/Arduino/build/linux/work/libraries/Morse/Morse.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token
     [exec] /home/jackie/Development/Code/Arduino/build/linux/work/libraries/Morse/Morse.c:10: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token
     [exec] /home/jackie/Development/Code/Arduino/build/linux/work/libraries/Morse/Morse.c:18: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token

Any ideas?

Thanks!

In morse.c, change "wprogram" to

Changed to...

#include <WProgram.h>
#include "Morse.h"

Also tried

#include <WProgram.h>
#include <Morse.h>

Response

jackie@jackie-Latitude-E6410:~/Development/Code/Arduino/libraries/Morse$ gcc Morse.c
Morse.c:1:22: fatal error: WProgram.h: No such file or directory
compilation terminated.
jackie@jackie-Latitude-E6410:~/Development/Code/Arduino/libraries/Morse$ ls
Morse.c  Morse.h

I will go over the link in a bit, any other ideas in the meantime?

What happens if you don't include it?

The WProgram.h should be added by the Arduino package by default. Mine does.
It is in the Arduino includes if you need it outside the Arduino package.
/arduino/cores/arduino/WProgram.h

Try adding a return type for the Morse function. Like this:

void Morse::Morse(int pin)
{
  pinMode(pin, OUTPUT);
  _pin = pin;
}

Change it in the Morse.h file also.

class Morse
{
  public:
    void Morse(int pin);
    void dot();
    void dash();

ADD: To stay with the norms of the Arduino/Atmel code, I would have called that function

void Morse::begin(int pin)

I see who wrote that Morse program. Isn't this the guy that maintains the Arduino IDE?
I like to know what weaknesses a programmer has if I am about to troubleshoot other code by the same programmer.

BTW, mine is mismatched curly braces. If I post code here, that is the first thing you should check.
That is why I may seem so anal about the curly brace alignment and indentation on my code.

Thanks I will try this... remember when it come to "should be included" that I am compiling this from source and not using apt-get or something similar. Again I am a little new to C do you know how to include a header file from another directory?

P.S. I don't see that header. Do I need to compile something differantly?

jackie@jackie-Latitude-E6410:~/Development/Code/Arduino/core$ ls
api.txt  build.xml  done.txt     make.sh  preproc     src
bin      core.jar   license.txt  methods  preproc.pl  todo.txt

Jackie

That directory listing appears to be the build directory. If you want to know if it is working, try this short code. If the noTone function does not generate a compiler error, the WProgram.h file has been included.

void setup()
{
  noTone(13);  
}

void loop()
{
  
}

These both include a header file. The first includes the WProgram.h file from the default include directory. The second includes the file from the current directory.

#include <WProgram.h>
#include "WProgram.h"

I do not need either of those to compile that code in the Arduino IDE.

So after I execute ant on the build directory, where does it get built to? Do I have to have the header file in my classpath like Java? Where would the header file be after I built the project?

Finally found the WProgram.h file it is in...

./hardware/arduino/cores/arduino

Anyone have any helpful tips on how to include or install it?

Tried this... no dice still...

jackie@jackie-Latitude-E6410:~/Development/Code/Arduino/libraries/Morse$ gcc -I ../../hardware/arduino/cores/arduino/ -c ./Morse.c 
In file included from ./Morse.c:1:0:
../../hardware/arduino/cores/arduino/WProgram.h:8:27: fatal error: avr/interrupt.h: No such file or directory
compilation terminated.

My apology for not getting back to you sooner. It was imperative I get my version of the Arduino compiler working.

You should be able to put it in the same directory as your code.
Then use
#include "WProgram.h"

EDIT: I see you have other challenges with the includes in the WProgram.h file.

I suggest remove the
#include "Wprogram.h"
statement from the code. That code shouldn't need it. There is nothing but setting pins and delay().

I took a look at the WProgram.h file. It appears to be a function set for producing an audible tone if you had an audio amp connected. Not required if you are just flashing the pin 13 LED.

Thanks I will try out removing it (and no worries about response time we are all busy)...

You should be able to put it in the same directory as your code.
Then use
#include "WProgram.h"

When you say "it" do you mean I can just copy the WProgram.h header file into the same directory? I am new to C so is the header file just an interface description and has no need for a class or object file?

Thanks

Jackie

http://code.google.com/p/arduino/wiki/Arduino1

Renamed WProgram.h to Arduino.h.

RENAME WProgram.h to Arduino.h in the cpp file of library

i can't use Ultrasonic when i click verify i see this message Why ?!!!!!!!!!!!!!!!

Arduino: 1.6.0 (Windows 7), Board: "Arduino Uno"

In file included from UltrasonicDemo.pde:1:0:
C:\Users\user\Documents\Arduino\libraries\Ultrasonic/Ultrasonic.h:11:22: fatal error: WProgram.h: No such file or directory
#include "WProgram.h"

^
compilation terminated.
Error compiling.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

Why ?

Because you have good eyesight.

If you want to resolve the problem, do what everyone else does. Edit the file that generates the error, and change WProgram.h to Arduino.h.