Wrapper class- undefined reference to..

Hi guys.

I have the following error while compiling the code:

First_Test.cpp.o: In function `__static_initialization_and_destruction_0':
C:\Program Files (x86)\Arduino/First_Test.ino:11: undefined reference to `SFR_Control::SFR_Control(int)'
First_Test.cpp.o: In function `loop':
C:\Program Files (x86)\Arduino/First_Test.ino:19: undefined reference to `SFR_Control::Check_2_close()'

The Sketch file is:

#include "C:\Program Files (x86)\Arduino\libraries\SFR05\SFR05.h"
#include <CAR_LCD_Display.h>
#include <LiquidCrystal.h>
#include <Arduino.h>


#define Trg_pin 3

CAR_LCD_CONTROL LCD (32,30,28,26,24,22);

SFR_Control Front (3);
void setup ()
{
  Serial.begin(9600);
}

void loop ()
{
  bool i = Front.Check_2_close() ;
    if (i)
  {
    LCD.Write_Direct("Too Close",0);
  }
}

the Header file is:

#ifndef _SFR_05_H
#define _SFR_05_H



#define DEBUG 
typedef unsigned char BYTE;
#define Max_Str_Len 40
#define Minumum_Distance 30 //cm
#define Speed_Of_Sound 0.017 // cm/us/2

class SFR_Control  {
	public:
	
  

		SFR_Control(int tgr_pin);//
		bool	Preform_Measure		(void);
		bool    Check_2_close();
		void	Set_Distance_Meas	(int Dist);
		void	Set_Startup_Meas	(int Dist);
		void	Set_Shutdown_Meas	(int Dist);
		int		Get_Distance_Meas	();
		int		Get_Startup_Meas	();
		int		Get_Shutdown_Meas	();
		void	Set_Triger_pin		(int trg);
		int		Get_Triger_pin		();
		int *   Get_Median_arr		();
		void	Set_Median_arr	(int data, int index);
	// Variables
		int Distance_Measured;
		int Startup_Meas;
		int Shutdown_Meas;
		int Triger_pin;
		int Median_arr[11];
		
};

#endif /* not defined  */

and the implementation is:

#include "SFR05.h"
#include "Arduino.h"


SFR05::SFR05(int tgr_pin)
{
	this->Set_Triger_pin(tgr_pin);
	pinMode(tgr_pin, OUTPUT);
	digitalWrite(tgr_pin, LOW);
}


bool SFR05::Preform_Measure(void)
{
	int tmp;
	if (DEBUG) Serial.print("Measuring Distance sq. start");
	digitalWrite(this->Get_Triger_pin(), LOW);
	delayMicroseconds(2);
	digitalWrite(this->Get_Triger_pin(), HIGH);
	delayMicroseconds(10);
	digitalWrite(this->Get_Triger_pin(), LOW);
	pinMode(this->Get_Triger_pin(), INPUT);
	tmp = pulseIn(this->Get_Triger_pin(), HIGH);
	this->Set_Distance_Meas ( tmp / 58); // Speed of sound 0.034 [cm/us]  divide by 2 is = 0.017 which is aprox 1/58;
	if (tmp == 0) return false;
	return true;
}

bool SFR05::Check_2_close()
{
	int meas;
	int len = sizeof(this->Get_Median_arr()) / sizeof (this->Get_Median_arr()[0]);
	for (int i = 0; i < len; i++)
	{
		meas=this->Preform_Measure();
		this->Set_Median_arr(meas, i);
	}

	//Insertion Sort

	{
		int key;
		int i;
		for (int j = 1; j<len; j++)
		{
			key = this->Get_Median_arr()[j];
			i = j - 1;
			while ((i >= 0) && (this->Get_Median_arr()[i]>key))
			{
				this->Get_Median_arr()[i + 1] = this->Get_Median_arr()[i];
				i--;
			}
			this->Get_Median_arr()[i + 1] = key;
		}
	}
	//int place =;
	if (this->Get_Median_arr()[len/2] <= Minumum_Distance)
	{
		//CAR_LCD05::Write_Direct("Too Close Break!!!",0);
		return true;
	}
	return false;	
}



void SFR05::Set_Distance_Meas(int Dist)
{
	Distance_Measured = Dist;
}

void SFR05::Set_Startup_Meas(int Dist)
{
	Startup_Meas = Dist;
}

void SFR05::Set_Shutdown_Meas(int Dist)
{
	Shutdown_Meas = Dist;
}

int SFR05::Get_Distance_Meas()
{
	return Distance_Measured;
}

int SFR05::Get_Startup_Meas()
{
	return Startup_Meas;
}

int SFR05::Get_Shutdown_Meas()
{
	return Shutdown_Meas;
}

void SFR05::Set_Triger_pin(int trg)
{
	Triger_pin = trg;
}

int SFR05::Get_Triger_pin()
{
	return Triger_pin;
}


int * SFR05::Get_Median_arr()
{
	return Median_arr;
}

void SFR05::Set_Median_arr(int data, int index)
{
	Median_arr[index] = data;
}



#endif /* not defined _CAR_LCD_DISPLAY_H */

I cant figure out where is the problem coming from, please your advise.

extern "C" {
  #include "Arduino.h"
}

Why is this in an extern "C" wrapper?

#include "C:\Program Files (x86)\Arduino\libraries\SFR05\SFR05.h"

Wrong. All you should need is the file name.

While searching for answers for the issue I've tried the extern "C" statement , thinking it would solve the problem.

When i write only the file name i have the following error:

First_Test.ino:1:19: warning: SFR05.h: No such file or directory
First_Test:11: error: 'SFR05' does not name a type
First_Test.ino: In function 'void loop()':
First_Test:21: error: 'FR' was not declared in this scope

at the beginning of the compilation, when the first error appears in the end of the compilation.

thanks

Usually you see these kinds of error messages when the library files are installed in the wrong place. Check your FIle--> Preference menu sequence in the IDE to see if the libraries are in the libraries subdirectory. Also, using:

#include "Alibrary.h"

looks in the current working directory for the header file, while:

#include <Alibrary.h>

looks in the default library directory. Note the use of double-quotation marks versus angle brackets. You might check where the library files are located.

I found out that is i copy the .c file into .h the error disappears.

You'd be better off to fix it the right way.

I found out that is i copy the .c file into .h the error disappears.

The .c file? You can't implement a class in a .c file. It MUST be in a .cpp file. No wonder it didn't work.

Yea that was my mistake, thanks guy's for the support.