cunit-testingcmakeunity-test-framework

Linker error with Unity (C unit testing framework)


I've littered through Stackoverflow trying to get Unity unit test framework (https://www.throwtheswitch.org/unity) linked and built on CMAKE so that I can write unit tests but I keep hitting this same error:

Undefined symbols for architecture x86_64:
  "_setUp", referenced from:
      _UnityDefaultTestRun in libunity.a(unity.c.o)
  "_tearDown", referenced from:
      _UnityDefaultTestRun in libunity.a(unity.c.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/test_problem2_59.exe] Error 1
make[1]: *** [tests/CMakeFiles/test_problem2_59.exe.dir/al

I have documented my final attempt here https://github.com/aamarin/computer_systems/tree/dev with the latest commit being the unstable commit. I'm not sure what else I'm missing in computer_systems/tests/CMakeLists.txt to get this working. Just looking for some guidance and maybe an explanation I might be missing from here https://gitlab.com/CLIUtils/modern-cmake/-/blob/master/examples/extended-project/src/CMakeLists.txt. Guidance on better structuring my folder structure is helpful as well.


Solution

  • Just add empty functions named setUp and teadDown. UnityGettingStartedGuide.