Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Support building in PlatformIO #20

Closed
wants to merge 1 commit into from
Closed

Support building in PlatformIO #20

wants to merge 1 commit into from

Conversation

eg321
Copy link

@eg321 eg321 commented Jul 5, 2020

There are bunch of "multiple definition of 'ESP_WiFiManager' functions" errors at linking process in PlatformIO like:

.pio\build\esp32\src\main.cpp.o: In function ESP_WiFiManager::handleReset()': \.platformio\lib\arduinojson_id64\src\arduinojson\Serialization/JsonWriter.hpp:46: multiple definition of ESP_WiFiManager::handleReset()'
.pio\build\esp32\src\NidayandHelper.cpp.o:\motor-on-roller-blind-ws-master/.pio/libdeps/esp32/ESP_WiFiManager_ID6915/src/ESP_WiFiManager-Impl.h:1339: first defined here
.pio\build\esp32\src\main.cpp.o: In function ESP_WiFiManager::handleWifiSave()': main.cpp:(.text._ZN15ESP_WiFiManager14handleWifiSaveEv+0x0): multiple definition of ESP_WiFiManager::handleWifiSave()'
.pio\build\esp32\src\NidayandHelper.cpp.o:NidayandHelper.cpp:(.text._ZN15ESP_WiFiManager14handleWifiSaveEv+0x0): first defined here
.pio\build\esp32\src\main.cpp.o: In function ESP_WMParameter::ESP_WMParameter(char const*)': main.cpp:(.text._ZN15ESP_WMParameterC2EPKc+0x0): multiple definition of ESP_WMParameter::ESP_WMParameter(char const*)'
.pio\build\esp32\src\NidayandHelper.cpp.o:NidayandHelper.cpp:(.text._ZN15ESP_WMParameterC2EPKc+0x0): first defined here
.pio\build\esp32\src\main.cpp.o: In function ESP_WMParameter::ESP_WMParameter(char const*)': main.cpp:(.text._ZN15ESP_WMParameterC2EPKc+0x0): multiple definition of ESP_WMParameter::ESP_WMParameter(char const*)'
.pio\build\esp32\src\NidayandHelper.cpp.o:NidayandHelper.cpp:(.text._ZN15ESP_WMParameterC2EPKc+0x0): first defined here
.pio\build\esp32\src\main.cpp.o: In function `ESP_WMParameter::init(char const*, char const*, char con

I'm not experienced CPP-developer, but there shouldn't be a implementation inside headers, it should be in .cpp.
This pull request fixes that and it's building ok in Platformio now.

I don't have configured Arduino IDE, so it's not tested there actually. Will be great if someone test in Arduino IDE before merging also.

Thanks.

@eg321
Copy link
Author

eg321 commented Jul 7, 2020

Hi, @khoih-prog.
Can you take a look to proposed changes please?

@khoih-prog
Copy link
Owner

There are many libraries currently using this new better way of aaa.h and aaa_Impl.h because of some benefits.

It's possibly not compatible with the way you're using: mixing aaa.h, aaa_Impl.h and multiple cpp files.

I suggest you do this way to be compatible with this library and many more

  1. Rename the NidayandHelper.cpp to NidayandHelper_Impl.h
  2. Modify the NidayandHelper.h and NidayandHelper_Impl.h as follows:
  • For NidayandHelper.h
...
#include "NidayandHelper_Impl.h"

#endif
    • For NidayandHelper_Impl.h
#ifndef NidayandHelper_Impl_h
#define NidayandHelper_Impl_h

#include "Arduino.h"
//#include "NidayandHelper.h"

....

#endif    //NidayandHelper_Impl_h

I also attach the zipped files of your whole project motor-on-roller-blind-ws, already converted to use this ESP_WiFiManager for you to try

motor-on-roller-blind-ws-master.zip

@khoih-prog khoih-prog closed this Jul 7, 2020
@eg321
Copy link
Author

eg321 commented Jul 8, 2020

@khoih-prog, can you describe some benefits of such naming please?

I was sure that your library is some replacement of popular tzapu / WiFiManager, and application was quite easy adapted for it during movement to ESP32.
But it looks quite strange for me now that your library requires some renaming in application also. It wouldn't help to make your library popular, I believe.

khoih-prog added a commit that referenced this pull request Oct 15, 2020
### Releases v1.2.0

1. Restore cpp code besides Impl.h code to use in case of `multiple definition` linker error. See [`Change Implementation to seperate *.h and *.cpp file instead of *.h and *-Impl.h`](#38) and [`Support building in PlatformIO PR`](#20). SSee [**HOWTO Fix `Multiple Definitions` Linker Error**](https://github.com/khoih-prog/ESP_WiFiManager#HOWTO-Fix-Multiple-Definitions-Linker-Error)
2. Fix bug [/close does not close the config portal](khoih-prog/ESPAsync_WiFiManager#16).
khoih-prog added a commit that referenced this pull request Oct 15, 2020
### Releases v1.2.0

1. Restore cpp code besides Impl.h code to use in case of `multiple definition` linker error. See [`Change Implementation to seperate *.h and *.cpp file instead of *.h and *-Impl.h`](#38) and [`Support building in PlatformIO PR`](#20). Also have a look at [**HOWTO Fix Multiple Definitions Linker Error**](https://github.com/khoih-prog/ESP_WiFiManager#HOWTO-Fix-Multiple-Definitions-Linker-Error)
2. Fix bug [/close does not close the config portal](khoih-prog/ESPAsync_WiFiManager#16).
khoih-prog added a commit to khoih-prog/ESPAsync_WiFiManager that referenced this pull request Oct 16, 2020
### Releases v1.2.0

1. Restore cpp code besides Impl.h code to use in case of `multiple definition` linker error. See [`Change Implementation to seperate *.h and *.cpp file instead of *.h and *-Impl.h`](khoih-prog/ESP_WiFiManager#38) and [`Support building in PlatformIO PR`](khoih-prog/ESP_WiFiManager#20). Also have a look at [**HOWTO Fix Multiple Definitions Linker Error**](https://github.com/khoih-prog/ESPAsync_WiFiManager#HOWTO-Fix-Multiple-Definitions-Linker-Error)
2. Fix bug [/close does not close the config portal](#16).
khoih-prog added a commit to khoih-prog/ESPAsync_WiFiManager that referenced this pull request Oct 16, 2020
### Releases v1.2.0

1. Restore cpp code besides Impl.h code to use in case of `multiple definition` linker error. See [`Change Implementation to seperate *.h and *.cpp file instead of *.h and *-Impl.h`](khoih-prog/ESP_WiFiManager#38) and [`Support building in PlatformIO PR`](khoih-prog/ESP_WiFiManager#20). Also have a look at [**HOWTO Fix Multiple Definitions Linker Error**](https://github.com/khoih-prog/ESPAsync_WiFiManager#HOWTO-Fix-Multiple-Definitions-Linker-Error)
2. Fix bug [/close does not close the config portal](#16).
khoih-prog added a commit to khoih-prog/ESPAsync_WiFiManager that referenced this pull request Oct 16, 2020
### Releases v1.2.0

1. Restore cpp code besides Impl.h code to use in case of `multiple definition` linker error. See [`Change Implementation to seperate *.h and *.cpp file instead of *.h and *-Impl.h`](khoih-prog/ESP_WiFiManager#38) and [`Support building in PlatformIO PR`](khoih-prog/ESP_WiFiManager#20). Also have a look at [**HOWTO Fix Multiple Definitions Linker Error**](https://github.com/khoih-prog/ESPAsync_WiFiManager#HOWTO-Fix-Multiple-Definitions-Linker-Error)
2. Fix bug [/close does not close the config portal](#16).
@eg321 eg321 deleted the support-platformio branch June 27, 2021 10:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants