Collect2.exe: error: ld returned 1 exit status : cannot find how to solve it

No, that’s just the final “aww linking failed :(” message, the actual error messages are above that, e.g. “multiple definition of…” / “undefined reference to…”. However even if you didn’t give us the actual error message, we can figure out the problem from your code…

Not indented correctly.

lib_deps =
   adafruit/TinyLoRa @ ^1.4.0

Oh no. No defining global variables within a header file if there are multiple users of the header file. You need to refactor it so that the header file only has

extern int max31865CS;  // CS Pin for MAX31865

and the max31865.cpp file has

int max31865CS = 0; 

This otherwise leads to “multiple definition of…” linker errors.

This has been discussed at e.g. A new PlatformIO user coding wrong, getting multiple definition & first defined here errors - #2 by maxgerhardt.

1 Like