Go Down

Topic: Library Examples with config files. (Linking issues) (Read 885 times) previous topic - next topic

Protoneer

Hi.

I am trying to turn a non-arduino application into an Arduino Library.

It has the following structure:

  • main.ino
    config.h
    utils.h
    utils.cpp




It works fine if all of it is in the same folder.

As soon as I create a library with the utils.h/cpp and add an example folder with the main.ino and config.h it returns the following error:

In file included from main.ino:30:
C:\arduino-1.0.3\libraries\test/utils.h:28:20: error: config.h: No such file or directory

How would I get around this?

The reason I have the config in the example folder is because I want to create one example for each Arduino Board with config specific to that board.
Delta 3D Printer with Auto Bed Leveling - http://www.kickstarter.com/projects/ttstam/openbeam-kossel-pro-a-new-type-of-3d-printer/posts
http://blog.Protoneer.co.nz

Coding Badly


As you've discovered, what you are trying to do doesn't work.

You can...

• Modify the Arduino IDE so the sketch folder is added to the include path (and many folks would be grateful)

• Modify your library so configuration parameters are passed to an initialization function / method.

Protoneer

#2
Mar 12, 2013, 08:27 am Last Edit: Mar 12, 2013, 08:52 am by Coding Badly Reason: 1

Do you have a link to the Arduino IDE code? I would not mind taking it apart... The IDE is just a simple wrapper so it might not be that hard.

Your second option sounds a lot like dependency injection where you need to inject all your data/settings/object into the constructor/Initializing function. (That will be a lot of work cause I have hundreds of settings.)

thinking of it, I could use a define statement that specifies the board type and configures the config file based on that. Might be the best option as the user starting out with the library will then not see the hundreds of settings and get confused by it.

Delta 3D Printer with Auto Bed Leveling - http://www.kickstarter.com/projects/ttstam/openbeam-kossel-pro-a-new-type-of-3d-printer/posts
http://blog.Protoneer.co.nz

Coding Badly

Do you have a link to the Arduino IDE code?


https://github.com/arduino/Arduino/

Quote
thinking of it, I could use a define statement that specifies the board type and configures the config file based on that. Might be the best option as the user starting out with the library will then not see the hundreds of settings and get confused by it.


I suspect your potential users would appreciate that.

Protoneer

Delta 3D Printer with Auto Bed Leveling - http://www.kickstarter.com/projects/ttstam/openbeam-kossel-pro-a-new-type-of-3d-printer/posts
http://blog.Protoneer.co.nz

Go Up