Go Down

Topic: Linking .h files between sketch and a library (Read 896 times) previous topic - next topic

Christo

I'm using the v-usb for Arduino library http://code.google.com/p/vusb-for-arduino/.  It contains a keyboard demo which I have copied to my /sketchbook/libraries folder.  This compiles no problem.  My only problem is that there is a usbconfig.h file that ships with the library that in my opinion should actually sit with the user sketch, since this file needs to be configured per sketch in principle.  My problem is that the sketch doesn't compile if I copy the usbconfig.h file from the library folder into the sketch folder.  The error I then get is: /sketchbook/libraries/UsbKeyboard/usbdrv.h:13:23: error: usbconfig.h: No such file or directory.  This happens even though I have
Code: [Select]
#include "usbconfig.h"
#include "usbdrv.h"
at the top of the sketch.

So my question is how do I correctly separate user configuration from the library folder while maintaining the following sequence of includes:
User sketch #include a library file (usbdrv.h) residing in the libraries folder,  the library file in turn #include a user supplied config file (usbconfig) located in the sketch folder?

Jimmy60

You can work with a library and your sketch at the same time on the ide by using the tabs. Add a tab to your sketch named libname.h and a tab named libname.cpp (where libname is the library you want to work on). You still need to include them in your sketch. I don't know if they will conflict with installed libraries but if it does just delete the installed one. When you add or remove libraries or sketches you have to restart the IDE.

Is that what you were asking?

PaulS

There are two ways to include a header file:
Code: [Select]
#include "header.h"
and
Code: [Select]
#include <header.h>

Which symbols you use determines where the file is looked for. Experiment on your own to determine which is appropriate for what you want to do.

MichaelMeissner


There are two ways to include a header file:
Code: [Select]
#include "header.h"
and
Code: [Select]
#include <header.h>

Which symbols you use determines where the file is looked for. Experiment on your own to determine which is appropriate for what you want to do.


From a standards point of view, the angle brackets is for system files, and the double quotes is for files local to the project.

pYro_65

Include the settings file before including the library, however only the library .h will see the contents.
If you are not using template/inline code ( that normally is defined in the header ) you will not have any luck as .cpp files in the libraries are compiled independent of your sketch, so in reality the library .cpp is an object file before your sketch reaches the compiler.

Christo

Thank you for the replies.  I suspect that pYro_65 is very close to the root of my problem.

Go Up