Copy old version of IRremote and give it a new name

I have a number of robot cars and other projects that depend on the 2.x version of IRremote to work properly. I've looked into the possibility of updating the code to use the latest release and that is way beyond my ability. They need to read codes from IR remotes and interpret them to do something based on which button is pressed. If I compile with the latest library I get an error about obsolete function calls.

I know that I can use the library manager to install the needed version but the IDE will always install the latest version of all libraries whenever there is an update to any installed library.

Is there a way to create a copy of the needed version of the library and install it with a different name so I can have both the latest version of IRremote along with the older version?

Yes there is.

  • Copy the library you want to rename to a folder that will bear it's new name.
  • Rename the .h & .cpp files.
  • modify the IFDEF HEADER at the top of the .h file to represent it's new name
  • modify the .cpp file to have the reference to the new name for the .h file.

The Header in the .h file that prevents multiple loads of the header file looks something like this

#ifndef __SD_HACK_H__
#define __SD_HACK_H__

(this is for a SD.h mod i did)

and i the .cpp file of that library i found

#include "SD_hack.h"

Which originally was "SD.h"

After this you can include the library with it's new name in your sketch

I should mention that i do have the needed version in a zip file. I got it from one of the robot car company's website. I guess the real question is how would i modify that zip library to give it a new name

Thank you very much. That is exactly what I needed.

Do exactly what @Deva_Rishi said in the first reply. You'll just have to rename the files and fix the .cpp to include the new name.

I have a follow up question. If I did not already have a zip file of the needed version, would I be able to get the files I needed by rolling back the version in the library manager, and then copying that folder from the library folder?

Yes. After that the IDE would see it as a completely different library with a different name.

You can disable the automatic update. I do not get any popups that new versions of libraries or boards are available and I do not update them unless I see a need.

It might be useful to create a portable install of IDE 1.8.x (IDE 2.x does not support portable installs (yet)) tailored for the projects that use the older version of the IRremote library.

I use it for the different board packages to make sure that they don't interfere with each other (I've burned my fingers a couple of times). Each of the entries below is a full installation with its own packages and sketchbook directory (and hence its own directory for 3rd party libraries).

image

1 Like

This particular library - IRremote - turned out to be more involved. There are a large number of .cpp and .h files and they all had to be modified. In addition, there is a .json file that also had to be changed. After updating each file with the new library name, everything is working as desired. Thank you for pointing me in the right direction.

1 Like

Using a portable IDE is a very good suggestion. I would not have thought of it.
Thank you.

Yeah that happens, any file that has a reference to the renamed file needs that reference corrected. Mind you not all the files that the included .h file depend upon need to be renamed. The renamed file will include the files in the same folder first if the name is put in hyphens, but the compiler can be a bit unpredictable at times.

The json file apparently is where the library manager gets the library name. Until I changed the library name in it, the manager tried to overwrite the standard IRremote library.

I hope this discussion helps others. Thanks for all the great suggestions.

Aj yeah uh.. don't use the obrary manager to install the libraries (bith versions) Just download the Zip file from github, also the old one should still be there, otherwise, install the old one through the library manager, but install the new one from github. IrRremote is not builtin is it ?

IRremote isn’t automatically installed but it is available there without needing to download the zip from GitHub.

yes but the library manager will of course not do what you want it to do. I will explicitly mention the downloading the zip files from github next time.

I can’t guarantee that I won’t have issues in the future but for now, I have both libraries coexisting in my IDE.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.