Compile error with Arduino 1.8.8 release

Status
Not open for further replies.

Loyd Nelson

New member
Doing the following steps:
Installed latest Arduino IDE (version 1.8.8).
Installed latest Teensyduino (version 1.45).
Select example program Sweep (Arduino IDE: File->Examples->Servo->Sweep).
Select Board "Arduino/Genuino UNO" (Arduino IDE: Tools->Board->Arduino/Genuino UNO).
Compile the program.

The program compiles.
Now Select Board "Teensy 3.5" (Arduino IDE: Tools->Board->Teensy3.5).
Compile the program.
The following error occurs:
#error "This library only supports boards with an AVR, SAM, SAMD, NRF52 or STM32F4 processor."

Why? What to do?
 
Odd to pick the wrong board then change - maybe the IDE confused something? What OS?
What other details are in the console like the library used?
Multiple libraries were found for "Servo.h"
Used: T:\arduino-1.8.8\hardware\teensy\avr\libraries\Servo
Not used: T:\arduino-1.8.8\libraries\Servo

I have IDE 1.88 and the TD 1.45 b2 build on my Win 10 machine and just did a verify build for T_3.1/3.2 and T_3.5 and T_3.6 with no errors.

Using :: ...\hardware\teensy\avr\libraries\Servo\examples\Sweep

Then I picked genuine/uno then back to T_3.5 and verify build worked on all without issue?
 

Because you still have the example you opened from the File > Examples menu when Uno was selected. That one doesn't work on Teensy.

What to do?

Close the Window with this example (and make sure at least one other Window is still open, so Arduino doesn't completely quit due to closing the last open window).

Then again click File > Examples > Servo > Sweep.

Even though the code looks the same, because Teensy is selected in the Tools > Boards menu, the Arduino IDE is actually opening a different copy of the Servo example and using the Teensy version on Servo. When you click Verify, it will work.

If you switch back to Uno, it will (probably) still work because Teensy's version works on AVR chips. But if you switch to a board like STM32, the Teensy version of Servo will also fail to compile. Again, close the window and reopen from File > Examples. They all look the same, but you're actually opening a physically separate copy of Servo.
 
Interesting to know it holds static some of that when single instance of IDE otherwise changes the rest, of course just sticking with Teensy fixes that issue :)

To find the file path in post #2 a Ctrl+K in the IDE opens the folder of the sketch - that is how the path was displayed and would have shown the 'non-Teensy' source tree:: ...\arduino-1.8.8\libraries\Servo\examples\Sweep

Likewise the verbose console listing of the library used would have been 'non-Teensy':: Using library Servo at version 1.1.3 in folder: ...\arduino-1.8.8\libraries\Servo
 
Based on your suggestions I performed the following work:

Opened Arduino IDE, menu item Tools->Board set to "Arduino/Genuino UNO"
Select menu item File->Examples->Servo->Sweep
Press Verify button - compile successful.

Your suggestion: Close IDE window holding Sweep example (it became second window when Sweep loaded)
Not part of your suggestion but needed: Change Tools->Board to "Teensy3.5"
Your suggestion: Select menu item File->Examples->Servo->Sweep - opens second IDE window for sketch
Press Verify button: (unfortunately your assertion that it will work did not happen)

Error compiling for board Teensy 3.5
D:\Users\Loyd\Documents\Arduino\libraries\Servo\src/Servo.h:75:2: error:
#error: "This library only supports boards with an AVR, SAM, SAMD, NRF52 or STM32F4 processor."
Multiple libraries were found for "Servo.h"
Used: D:\Users\Loyd\Documents\Arduino\libraries\Servo
Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Servo
Not used: C:\Program Files (x86)\Arduino\libraries\Servo
Error compiling for board Teensy 3.5.

It appears that the include/lib search sequence did not change as you suggested it would.
I also tried just starting the Arduino IDE (with Board: Teensy 3.5 already the default) and got the same error. I also tried "defragster's" suggestion of a "Ctrl-K" to see what sketch I was actually loading. It was D:\Users\Loyd\Documents\Arduino\libraries\Servo\examples\Sweep (I don't have an Arduino-1.8.8 - the Arduino install wipes out the old version and only installs Arduino). I loaded the Teensy Sweep example in C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Servo\examples\Sweep to see if that made a difference. It is the same program.

I don't know how to change the include/lib search sequence but have a feeling that would solve the problem (as you suggested, Paul). So I brute-forced it and moved the D:\Users\Loyd\Documents\Arduino\libraries\Servo folder to another location and tried again. The Verify worked!! Teensy definitely likes its own libraries. Now the question is: how come the include/lib search sequence does not change when I select the Teensy 3.5 board? Is there a way I can change the include/lib search sequence in the Arduino IDE?

I want you both to know that I really appreciate your quick response and the giving of your time trying to help. Good deeds are definitely counted in heaven.
 
Incidentally, FYI: I compared the Arduino Servo.h file against the Teensy Servo.h file and there is a difference in the builtin timers and how they are used. So it is important that the Teensy include file be used for the Teensy.
 
I have a fresh copy of Arduino 1.8.8 on MAC with the new just released Teensy release.

I did an example->servo->sweep and it compiled fine for me for T3.5...

Note: if you have a copy of the servo library in your <arduino sketch folder>/libraries
That one will always be used and if it is a specific one that does not work for Teensy...

Easiest fix is to just delete that one and use the one installed by Teensy.

When you compile, does it tell you a path for the library that is failing to compile?
 
If you ever noticed the few second delay in UI response when changing the Board - it seems to me that the IDE is internally parsing and updating the paths "to change the include/lib search sequence" to the selected board.

Also I started downloading the ZIP of the IDE and extracting to a unique folder by IDE Version. I did the 'Install' some few times when I started with Teensy on 1.6.0 and the IDE seemed to have a mind of its own with some defaults. Once I started doing the Zip>Extract I can maintain multiple versions easily and the IDE works without side effects from what seemed to be some built in default preferences. Also the IDE Zip>Extract folder can be copied to other machines (or a copy with a new name) and works perfectly well.
 
Ah, now we can see the real problem.

Multiple libraries were found for "Servo.h"
Used: D:\Users\Loyd\Documents\Arduino\libraries\Servo
Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Servo
Not used: C:\Program Files (x86)\Arduino\libraries\Servo
Error compiling for board Teensy 3.5.

Looks like at some point you installed a copy of Servo in your Documents\Arduino\libraries folder.

When you do this, your installed library always overrides any others with the same name. It's a powerful feature which lets you override any library with your own copy, which is especially nice if you want to edit that library's code.

But it's also really easy to do this at some point to solve a specific problem, Maybe you were using a STM32 board that didn't work with Servo, and the solution was to put a custom copy of Servo for STM32 into Documents\Arduino\libraries? Then months or years later, when that old problem is long forgotten, Arduino is still using that specialized copy of Servo and never any installed by other boards, like Teensy's copy of Servo in C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Servo. STM32's copy probably supports their boards and most of Arduino's AVR ones, but wouldn't have any code to support Teensy.

I contributed this "Multiple libraries" message to Arduino's build process years ago (back in the 1.6.x days) because this confusing problem happens to so many people. Thankfully, the Arduino devs has kept it in the code as they've changed so much, though in many cases it now only appears if you have "verbose output" enabled in File > Preferences. Back in 1.6 it would always print if multiple copies were found.

Simplest solution would be to delete Documents\Arduino\libraries\Servo. Or just move it somewhere else on your computer, so it's not in the special Documents\Arduino\libraries to overrides everything installed in Arduino.
 
Paul, your suggestion is what I had already done - move the Servo folder out of the Arduino\libraries. The Teensy code compiles fine then. I work with both the Teensy and the Arduino UNO so it will be kind of a pain to keep moving the folder when I switch controllers but I don't change too often and will put up with it for now. I consider this forum item closed now.
 
The correct solution - the official way Arduino's IDE is meant to be used - is each "platform" you install is supposed to have its own customized copies of libraries like Servo.

That's why Teensy's version is Servo is in C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Servo. The Arduino IDE automatically notices we've put a copy of Servo in that hardware\teensy\avr\libraries folder and uses it when you have Teensy selected. Or it's supposed to, but of course anything you've personally put into Documents/Arduino/libraries overrides everything.

You could try to find where the files are located for STM32 or whatever other non-Arduino boards you're using and put the custom copy of Servo there. If you installed by the Boards Manager, it may be somewhere within the hidden AppData folder on Windows. If you just put that copy of Servo in the right location, and don't keep a copy in Documents/Arduino/libraries, then everything will work the way you want. The Arduino developers designed the software to work this way, but it does depend on each platform putting its customized libs in the correct place (as the Teensyduino installer does).

Or you could ask the STM32 folks to start including their Servo library this way. That's how Arduino is meant to work. Or perhaps they already have done that? Best to check whether you're using the latest version before asking them for something.
 
Status
Not open for further replies.
Back
Top