Got the following strange error when trying to run the unit tests on the platformio calculator example while figuring out how to do unit tests on native.
C:/msys64/mingw64/bin/…/lib/gcc/x86_64-w64-mingw32/13.1.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: .pio\build\native\lib49a\libcalculator.a: error adding symbols: archive has no index; run ranlib to add one
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\native\program.exe] Error 1
Building stage has failed, see errors above. Use pio test -vvv option to enable verbose output.
I had installed Mingw via MSYS2 following their installation documentation. Couldn’t figure out what the heck was wrong that would cause this strange error, but suspected some issue with the compiler, so eventually uninstalled MSYS2 and all packages.
Then I installed MinGW via chocolatey which at writing using Mingw 12.2 (via MSYS2, version was 13.2). This solved the error and tests began to run without issue.
Not sure if anybody knows what the issue here is. Maybe it was an installation mistake on my part via MSYS2, or if it actually is the version that makes the difference. Either way, it is working for me now and thought I would make a post in case anybody else is currently struggling with this issue.
Usually PlatformIO has a “Generating archive index” step which exactly executes ranlib or gcc-ranlib, but this does not seem to be happening for platform = native (?).
Thanks for your post! I ran exactly into the same issue and after a lot googling I finally came across your post. Will try it right away!
Take it as a confirmation for your “post in case anybody else is currently struggling with this issue”
Now, I installed MinGW via chocolatey (great tip, btw!) which installed mingw13.2 - same issue in platform.IO (archive has no index)
After installing MinGW 12.2 testing works!
Conclusion: MinGW 13.2 seems not to work with platform.IO; 12.2 has to be used.
Issue filed at github under platformio/platform-native/issues/25