I am trying to use the unity unit test framework in ‘native’ mode. When it gets to the link step ld fails with the following message:-
ld: archive member '/' not a mach-o file in '/Users/alan/Documents/PlatformIO/Projects/unitytest/.pio/build/native/lib1ea/libUnity.a'
Here’s my platformio.ini file (very simple!)
[env:native]
platform = native
test_framework = unity
Here’s the full build using -vvv for pio test -e native -vvv
alan@Beaky-Mac unitytest % pio test -e native -vvv
Please wait while upgrading PlatformIO...
PlatformIO has been successfully upgraded to 6.1.16a1!
******************************************************************************************************************************************
If you like PlatformIO, please:
- star it on GitHub > https://github.com/platformio/platformio-core
- follow us on LinkedIn to stay up-to-date on the latest project news > https://www.linkedin.com/company/platformio/
- try PlatformIO IDE for embedded development > https://platformio.org/platformio-ide
******************************************************************************************************************************************
Collected 1 tests (test_dummy)
Processing test_dummy in native environment
------------------------------------------------------------------------------------------------------------------------------------------
Building...
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 2 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Unity @ 2.5.2 (License: MIT, Path: /Users/alan/Documents/PlatformIO/Projects/unitytest/.pio/libdeps/native/Unity)
Building in test mode
gcc -o .pio/build/native/unity_config_build/unity_config.o -c -DPLATFORMIO=60116 -DPIO_UNIT_TESTING -DUNIT_TEST -DUNITY_INCLUDE_CONFIG_H -Iinclude -Isrc -I.pio/libdeps/native/Unity/src -I.pio/build/native/unity_config -I.pio/build/native/unity_config -Itest/test_dummy -Itest .pio/build/native/unity_config/unity_config.c
g++ -o .pio/build/native/test/test_dummy/test_dummy.o -c -std=c++11 -DPLATFORMIO=60116 -DPIO_UNIT_TESTING -DUNIT_TEST -DUNITY_INCLUDE_CONFIG_H -Iinclude -Isrc -I.pio/libdeps/native/Unity/src -I.pio/build/native/unity_config -I.pio/build/native/unity_config -Itest/test_dummy -Itest test/test_dummy/test_dummy.cpp
gcc -o .pio/build/native/lib1ea/Unity/unity.o -c -DPLATFORMIO=60116 -DPIO_UNIT_TESTING -DUNITY_INCLUDE_CONFIG_H -I.pio/libdeps/native/Unity/src -I.pio/build/native/unity_config .pio/libdeps/native/Unity/src/unity.c
ar rc .pio/build/native/lib1ea/libUnity.a .pio/build/native/lib1ea/Unity/unity.o
ranlib .pio/build/native/lib1ea/libUnity.a
g++ -o .pio/build/native/program .pio/build/native/unity_config_build/unity_config.o .pio/build/native/test/test_dummy/test_dummy.o -L.pio/build/native .pio/build/native/lib1ea/libUnity.a
ld: archive member '/' not a mach-o file in '/Users/alan/Documents/PlatformIO/Projects/unitytest/.pio/build/native/lib1ea/libUnity.a'
collect2: error: ld returned 1 exit status
*** [.pio/build/native/program] Error 1
Building stage has failed, see errors above. Use `pio test -vvv` option to enable verbose output.
--------------------------------------------- native:test_dummy [ERRORED] Took 0.46 seconds ---------------------------------------------
================================================================ SUMMARY ================================================================
Environment Test Status Duration
------------- ---------- -------- ------------
native test_dummy ERRORED 00:00:00.458
=============================================== 1 test cases: 0 succeeded in 00:00:00.458 ===============================================
I am using the gcc and g++ compilers installed via brew, but the linker appears to the be the Apple ld and the gcc project says that that is the linker to use on a Mac.
What am I doing wrong?
Thanks!