mcci-catena / arduino-lmic

LoraWAN-MAC-in-C library, adapted to run under the Arduino environment
https://forum.mcci.io/c/device-software/arduino-lmic/
MIT License
640 stars 208 forks source link

Making arduino-lmic competible with arduino-esp32-2.0 #714

Open chansheunglong opened 3 years ago

chansheunglong commented 3 years ago

I recently updated the arduino-esp32 to version 2.0 and when compiling the program

...\esp32\hardware\esp32\2.0.0-alpha1/tools/sdk/esp32/lib\libpp.a(hal_mac.o): in function hal_init': (.text.hal_init+0x100): multiple definition ofhal_init'; ...\MCCI_LoRaWAN_LMIC_library\src\hal/hal.cpp:416: first defined here collect2.exe: error: ld returned 1 exit status

Seems like the new version of arduino-esp32 (2.0) will not be compatible with arduino-lmic because of the same definition of a function.

Since ESP32 is quite a popular platform and making LMIC and ESP32 not able to work together is sad news, will it be possible for arduino-lmic to add an option, e.g. #DEFINE_USE_ESP32, to alter the naming of the function so there will be no multiple definition?

The old version of arduino-esp32 (1.6) works with arduino-lmic

terrillmoore commented 3 years ago

Very sorry about this. Not going to happen without a major rename pass. I suggest you add #define hal_init LMICHAL_init in your LMIC project config or on the PlatformIO command line where you define other LMIC options. Don't know when we'll have time to fix it here. Seems like a mistake for both libraries (ESP32 and LMIC) to use unqualified names that are not reserved names in the C standard.

marcobrianza commented 3 years ago

the #define fixed my project, If it does not harm, It could be a default in project config

terrillmoore commented 2 years ago

I have put this on the list to investigate in the next release.

1Ghasthunter1 commented 2 years ago

Very sorry about this. Not going to happen without a major rename pass. I suggest you add #define hal_init LMICHAL_init in your LMIC project config or on the PlatformIO command line where you define other LMIC options. Don't know when we'll have time to fix it here. Seems like a mistake for both libraries (ESP32 and LMIC) to use unqualified names that are not reserved names in the C standard.

Thanks, this seemed to work for me!

kallisti5 commented 1 year ago

Are there any plans to fix this? Seems weird to "just rename hal_init" moving forward forever.

arslan437 commented 7 months ago
#define hal_init LMICHAL_init 

worked for me

gillet51430 commented 5 months ago

define hal_init LMICHAL_init

worked for me too