Pages: [1]   Go Down
Author Topic: Library Examples with config files. (Linking issues)  (Read 800 times)
0 Members and 1 Guest are viewing this topic.
Wellington, New Zealand
Offline Offline
Jr. Member
**
Karma: 0
Posts: 65
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 206
Posts: 12850
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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.
Logged

Wellington, New Zealand
Offline Offline
Jr. Member
**
Karma: 0
Posts: 65
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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.

« Last Edit: March 12, 2013, 02:52:31 am by Coding Badly » Logged


Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 206
Posts: 12850
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Wellington, New Zealand
Offline Offline
Jr. Member
**
Karma: 0
Posts: 65
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for that...  smiley-cool
Logged


Pages: [1]   Go Up
Jump to: