Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed "optiLoad.h not found" error. #12

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Fixed "optiLoad.h not found" error. #12

wants to merge 6 commits into from

Conversation

aliebold
Copy link

In newer versions of Arduino IDE (1.6.x and 1.8.3) optiLoader does not compile because the optiLoader.h file is included too many times. This was corrected by using pre-compiler IF statements.

In newer versions of Arduino IDE (1.6.x and 1.8.3) optiLoader does not compile because the optiLoader.h  file is included too many times. This was corrected by using pre-compiler IF statements.
Copy link
Owner

@WestfW WestfW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The optiloader.ino change shouldn't be required (and aren't "standard practice"

@aliebold
Copy link
Author

You're absolutely right. I agree. However, the error is generated from the "#include optiLoader.h". I think this is primarily an issue with the IDE. The #ifndef in the .ino file is truly a work around. Basically, in Arduino it looks like it would work without the #include, but even Arduino says that you should #include an .h file.

This is the error that I'm trying to solve. Both the .ino and .h files are in the same folder (copied right out of the zip file). Adding the #ifndef in the .h file doesn't completely correct the issue. I started this journey in Arduino 1.6.(something) and now I've upgraded to Arduino 1.8.3. Both of them showed the same issue.
image

Would you rather I just submit a bug request? Admittedly, I am not a software engineer. :-)

aliebold added 2 commits June 20, 2017 13:28
Moving the header file optiLoader.h into a directory (./includes) prevents the Arduino IDE from automatically including it, causing conflicts.
@aliebold
Copy link
Author

I realized, this afternoon, that the Arduino IDE automatically includes all of the files in the root directory of a project and it expects them to be *.ino files. I ran into this issue today when I added the main optiloader code to my project as a cpp file. This threw tons of errors. This whole issue with optiLoader.h is solved by placing it inside of a directory, to prevent it from being auto included.

@WestfW
Copy link
Owner

WestfW commented Jun 20, 2017

Ok, this is getting a bit weird. I've duplicated your problem with a downloaded copy of optiLoader, but my "original" optiLoader (which nominally contains the same files) fails with the "bad include" message...

"the Arduino IDE automatically includes all of the files in the root directory of a project and it expects them to be *.ino files."
No, that's not the way it works. The IDE scans all of the files in the root directory, and acts on them DEPENDING on the extension:

  1. .ino files are concatenated in source form, processed with the special Arduino preprocessor, and compiled with C++ as one big file.

  2. .cpp, .c, and .S files are compiled with C++, C, or the assembler, one at a time, without special pre-processing.

  3. .h and similar files should be ignored.

I've had the IDE get really confused when it hits unexpected file types (autosaves and backup versions of source, created when using an external editor, for example.) But having both the .h and .ino in the top level directory should work fine...

@aliebold
Copy link
Author

It makes sense to me that it should work that way. However, it looks like the IDE is not ignoring the .h file. Here is a snapshot of my folder and how Arduino opened it. It pulled the .h in just like an .ino. I get the same results from double-clicking the .ino or opening the .ino from the IDE.
image

@WestfW
Copy link
Owner

WestfW commented Jun 20, 2017

Ah hah! Notice anything just a little bit wrong with this:
screen shot 2017-06-20 at 2 05 05 pm

The "sketch name" (optiLoader.ino) and the directory name "OptiLoader" do NOT match - they have different capitalization! Fix that and see if it works...
(I have no immediate explanation for why that mistake would cause that particular error; it's still pretty mysterious.)

aliebold added 3 commits June 21, 2017 09:43
Placing the files inside of the "optiLoader" folder will help ensure that the user has the project in a folder with a matching name and case.
Placing the files inside of the "optiLoader" folder will help ensure that the user has the project in a folder with a matching name and case.
@aliebold
Copy link
Author

I think you found it! It looks like Arduino checks that the names are the same, but ignores case. But, it seems that case alone can still break it. When I downloaded the project it is named OptiLoader-master and I just deleted the -master. That left me with the capital OptiLoader. In this fork I've moved the files into a correctly named folder and I restored them to your original files. I understand if you would like to make the changes yourself or fix it another way so that you don't get those 5 extraneous comits in your history.

Anyway, I'm glad we got this firgured out. Thank you for your help. This is a really great project. It is the key to some production test stands that I'm building.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants