Overwriting base includes

I’m trying to convert an arduino project to run on platform IO. I have a PR in for wifimulti that adds some functionality that I am using in this project. Where can I put the h and cpp files so the build includes my version of wifmulti instead of the repo version until they merge it?

Here are the docs on library folders. There are locations which are private to the project (lib_dir) and even to build environment (lib_extra_dirs). You should put your version of wifimulti in one of these.

That’s helpful. I’m very new to this.

Where/how do I tell the compiler to look in this folder for my version of wifimulti? I remember seeing a dialog for adding include paths but I can’t find it now…

I found the dialog. I tried adding the include path to both the top and bottom of the include list, but it’s still throwing the error saying that indicates that the compiler is not using this version.

I think your version of library should be one level below the lib_dir, just like all other libraries on your screenshot. That way you won’t need altering include paths.
By the way, you say you have added the include path, but it’s not visible on the provided screenshot.

1 Like

I’m not following you… Do you mean I should copy the cpp and h files directly into project/lib?

The include path is in a separate window:

Copying the files into project/lib didn’t work.

Definitely not, see my link to lib_dir description earlier. Every library should be put in its own subfolder. I’m not sure why PlatformIO cannot find your version of wifimulti, maybe @ivankravets or someone else from PlatformIO core team can help here.
But I see it’s placed deep inside the subfolder: esp32/libraries/wifi… Maybe moving wifi folder up would help? So that it’s located as lib/wifi?
Or, as a last resort, you can put the files into src folder, but it’s better to get it building as a separate library…

This screenshot is related to Intellisense only, i.e. visual hints about your code in the editor. Compiler include paths should be set in platformio.ini.

It shouldn’t work; the files should be located in a subfolder according to PlatformIO docs.

Yes. I moved those files into a subfolder and got past that point. New problem is this:

Thank you for your help and patience!

That’s because original library variant is compiled too. Do you have it listed in lib_deps? Remove it in that case.

Where is that? How do I do this? I don’t see it listed here:

That’s because it’s not listed :wink:

You shouldn’t have needed to modify the include path at all, as the default order of priority puts private libraries before those included with the core.

Instead, make sure you clean the project so that it has to rebuild from scratch, rather than trying to use previously compiled binaries. If you don’t, the compiler may still be trying to use the previously compiled binaries for the stock library.


If you want to reassure yourself that your version of the library is being used, shove a #warning in your version of the library inside the include guard, and see if it pops up during the compile…

Cleaning didn’t help. It still fails. I did get it to work by deleting the wifimulti files in .platformio\packages\framework-arduinoespressif32\libraries\WiFi\src

Interesting… As you can see… it (successfully) compiled for me by simply copying the library into the \lib folder… i.e .platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi into \lib, and then just adding a #warning Not the stock xxx.h! inside the include guard so I could verify from the compiler output that it was indeed using the private library, not core provided copy. This was without any changes to the include paths.

Anyway, it seems to be working for now, so probably best not to break it! :laughing:

@Daemach is it possible to get a copy of your project or minimal example which shows the problem?

It’s kind of a mess because I’m in the middle of porting it from arduino. Something just occurred to me though… I am not a C programmer. Am I including this correctly?

#include <WiFiMulti.h>
WiFiMulti wifiMulti;

or should it be

#include "WiFiMulti.h"
WiFiMulti wifiMulti;

It shouldn’t really matter. The < > format basically means look in the standard include paths whereas " " means look in the specified relative path first, then the include paths.