Library Question

Hello All,

Still working on my 3D LED cube. I am trying to clean up the code a bit now by converting it to libraries and objects. I have used objects in VB and C# but I am having trouble in Arduino. I have created a library and have successfully included it. I can even create the objects. The problem seems to be when I create and object that has a constructor. Here is the code.


#ifndef vector_h
#define vector_h

#include "Arduino.h"
#include "Quaternion.h"
#include "Matrix.h"

class vector
float x;
float y;
float z;
vector(float X, float Y, float Z);


#include "Arduino.h"
#include "Vector.h"
#include "Quaternion.h"
#include "Matrix.h"

vector::vector(float X, float Y, float Z)
x = X;
y = Y;
z = Z;

Then when I use the class like this...
vector v(f,f,f);

I get this as an error
Compiling 'Cube' for 'Arduino Mega 2560 or Mega ADK'
Cube.cpp.o : : In function `Testing()':
Cube.cpp : vector(float, float, float)'
avr-objcopy* : : 'C:\Users\Home\AppData\Local\VMicro\Arduino\Builds\Cube\mega2560\Cube.elf': No such file
avr-objcopy* : : 'C:\Users\Home\AppData\Local\VMicro\Arduino\Builds\Cube\mega2560\Cube.elf': No such file
Couldn't determine program size:

I can comment out the line and it compiles fine.

Any help would be truly appreciated.


Are the tabs for those files visible in the IDE?
If the files are not in the sketch directory, you need to use <> instead of quotes to include a file.

Interesting answer. I have placed the code in the libraries directory with other examples. “C:\Program Files (x86)\arduino-1.0.1\libraries

I created a folder called “Graphics3D” and in that folder I created a “Graphics3D.cpp” and “Graphics.h” file.


#ifndef Graphics3D_h
#define Graphics3D_h
#include “Arduino.h”
#include “Vector.h”
#include “Quaternion.h”
#include “Matrix.h”


#include “Arduino.h”
#include “Graphics3D.h”
#include “Vector.h”
#include “Quaternion.h”
#include “Matrix.h”

My plan is that by including Graphics3D in my project i Would get access to Vector, Quaternion and Matrix. I say interesting answer because I copied this Technic from the Ethernet.h and Ethernet.cpp files that come with the Arduino Software. Ethernet.h seems to use quotes for files that are in the same library directory and then “<>” symbols for ones I could not locate in the folder.


#include <inttypes.h>
//#include “w5100.h”
#include “IPAddress.h”
#include “EthernetClient.h”
#include “EthernetServer.h”
#include “Dhcp.h”

In my project my include had to look like this to not get an error.
#include “C:\Program Files (x86)\arduino-1.0.1\libraries\Graphics3D\Graphics3D.h”

I’ll play around the folders and try moving the code into my project.

Actually it worked like a charm. I place the files in my directory. I am using visual studio so I added the .h files to the header folder/filter and the cpp files to the resources folder/filter. I hope that is where they go? I did have to add math.h and it only worked with the <> symbols.

#include <math.h>

Thanks pYro_65