Hi
I'm making edits to the .cpp file of a library, and it occurs to me that the IDE may not note that the library needs recompiling when I recompile the .ino file that is calling the library. How does one assure recompile of the library?
Is it necessary to change boards, as Robin suggested here:
forcing-ide-avrdude-to-re-compile-libraries-after-changes-have-been-made
The verbose output will tell you when the cached library is being used:
For example, here you can see the "Servo" library was compiled from source:
Compiling library "Servo"
"C:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\mega" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\libraries\\Servo\\src" "C:\\Users\\per\\AppData\\Local\\Arduino15\\libraries\\Servo\\src\\avr\\Servo.cpp" -o "C:\\Users\\per\\AppData\\Local\\Temp\\arduino\\sketches\\695FC98B203411DB833CDB94C852F904\\libraries\\Servo\\avr\\Servo.cpp.o"
[...]
As long as you see output like that, you will know the IDE has automagically taken care of it for you and you don't need to take any action to force a recompile. I think you will find this is the case.
Here you can see the output from a subsequent compilation without any modifications to the library where the cache produced by the previous compilation is used:
Compiling library "Servo"
Using previously compiled file: C:\Users\per\AppData\Local\Temp\arduino\sketches\695FC98B203411DB833CDB94C852F904\libraries\Servo\renesas\Servo.cpp.o
Using previously compiled file: C:\Users\per\AppData\Local\Temp\arduino\sketches\695FC98B203411DB833CDB94C852F904\libraries\Servo\megaavr\Servo.cpp.o
Using previously compiled file: C:\Users\per\AppData\Local\Temp\arduino\sketches\695FC98B203411DB833CDB94C852F904\libraries\Servo\mbed\Servo.cpp.o
Using previously compiled file: C:\Users\per\AppData\Local\Temp\arduino\sketches\695FC98B203411DB833CDB94C852F904\libraries\Servo\samd\Servo.cpp.o
Using previously compiled file: C:\Users\per\AppData\Local\Temp\arduino\sketches\695FC98B203411DB833CDB94C852F904\libraries\Servo\sam\Servo.cpp.o
Using previously compiled file: C:\Users\per\AppData\Local\Temp\arduino\sketches\695FC98B203411DB833CDB94C852F904\libraries\Servo\nrf52\Servo.cpp.o
Using previously compiled file: C:\Users\per\AppData\Local\Temp\arduino\sketches\695FC98B203411DB833CDB94C852F904\libraries\Servo\stm32f4\Servo.cpp.o
Using previously compiled file: C:\Users\per\AppData\Local\Temp\arduino\sketches\695FC98B203411DB833CDB94C852F904\libraries\Servo\avr\Servo.cpp.o
Nope. Sorry to tell you, changes to the .cpp file don't cause a recompile very often, if at all. Haven't seen it detect the changes yet today. And yes, I verified in all cases, it is looking at the file I'm modifying.
And so, humbly, I return to this thread to suggest that my reading skills require improvement. In fact, the file is being recompiled now. Why now, not earlier, I'm not sure, but now I'm consistently seeing a recompile of the specific file I'm editing. I seriously wish I understood what has changed, because I am absolutely positive that it wasn't at the time I wrote the previous message, so there's something different. I searched preferences around that time, and changed compile warning level (to all from more), but I don't believe for a minute that had anything to do with it.
Oh well. (wipes egg off face). I got the change implemented that I wanted; it's not perfect yet, but my variant of Servo now manages servos in pairs, up to 9 of them (yes, 18 servos). That reduces the time it takes for Servo to finish it's interrupt-driven updates, allowing me to slip a 36-pixel update process into the end of the Servo updates.
Thanks, @ptillisch and @Delta_G, this thread can be closed, I think.
C
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.