Unexplained Solution with Library When Using Eclipse IDE with Arduino Uno

I recently successfully configured Eclipse to work with my Arduino Pro. Everything was working fine except, when I went to use the Adafruit provided NeoPixel Library I was having trouble compiling the factory code. Below is a portion of the code that I am working with which is commented to help illustrate my issue. When I created an instance of the Adafruit_Neopixel class I thought this would act as a global instance to all functions in this file but it didn’t. The only way that the compiler wouldn’t fuss about the instances of strip in setup() and loop() below is if I re-declared them in each of the functions. This obviously is a huge hassle, so I knew that there was a workaround.

#include <Adafruit_Neopixel/Adafruit_NeoPixel.h> [b]//First, I had to include the folder and file instead of just the file.  Is there a way around including the folder?[/b]
#include <math.h>
#include <Arduino.h> 

#define PIN 5

void rainbow(uint8_t wait);
void colorWipe(uint32_t c, uint8_t wait);
uint32_t Wheel(byte WheelPos);
Adafruit_NeoPixel strip = Adafruit_NeoPixel(150, PIN, NEO_GRB + NEO_KHZ800); 

void setup() {
  strip.begin();
  strip.show(); 
}

void loop() {
  colorWipe(strip.Color(255, 0, 0), 50); // Red
  rainbow(20);
  colorWipe(strip.Color(0, 255, 0), 50); // Green
  colorWipe(strip.Color(0, 0, 255), 50); // Blue
  rainbow(20);
  rainbowCycle(20);

}

The error that I would receive from the compiler when attempting to declare the instance, strip, globally was: “Undefined reference to…” followed by the various function names in the Adafruit_NeoPixel class. So, here comes the point of all of this and where I really need an explanation:

I decided to verify/compile the Adafruit_Neopixel pde in the original Arduino IDE in order to produce temporary compiled files in the windows explorer %TEMP% folder. When I did this I only found Adafruit_Neopixel.cpp**.o** and Adafruit_NeoPixel.cpp**.d**. I know that the eclipse library extension is .a, so I took a long shot and changed the .o file to .a. I then added the file with the changed extension to the AVR C++ Linker-> Libraries section within project properties->c/c++ build->settings->tool settings.

After I did this, I was able to compile and run perfectly fine with the instance of Adafruit_Neopixel unchanged still declared as global. I am sure I am ignorant to something and this accidental fix probably isn’t a good one. Can you please explain what I did that would cause this and suggest a better solution?. Thank you very much!

Please use code tags.

Read this before posting a programming question

How to use this forum

Thanks. Sorry, I read through it but I neglected to add the code tags as instructed.

I decided to verify/compile the Adafruit_Neopixel pde in the original Arduino IDE in order to produce temporary compiled files in the windows explorer %TEMP% folder. When I did this I only found Adafruit_Neopixel.cpp.o and Adafruit_NeoPixel.cpp.d. I know that the eclipse library extension is .a, so I took a long shot and changed the .o file to .a. I then added the file with the changed extension to the AVR C++ Linker-> Libraries section within project properties->c/c++ build->settings->tool settings.

You did what?

I just downloaded and installed their library, and their two examples compiled without error.

Oh, I see, you are using another IDE.

Maybe the author of Eclipse can help you.