首页 > 解决方案 > Unity 的链接器错误(C 单元测试框架)

问题描述

我在 Stackoverflow 中乱扔垃圾,试图将 Unity 单元测试框架 ( https://www.throwtheswitch.org/unity ) 链接并构建在 CMAKE 上,以便我可以编写单元测试,但我一直遇到同样的错误:

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

我在这里记录了我的最后一次尝试https://github.com/aamarin/computer_systems/tree/dev最新的提交是不稳定的提交。我不确定在 computer_systems/tests/CMakeLists.txt 中还缺少什么来使其正常工作。只是寻找一些指导,也许我可能会从这里缺少解释https://gitlab.com/CLIUtils/modern-cmake/-/blob/master/examples/extended-project/src/CMakeLists.txt。关于更好地构建我的文件夹结构的指导也很有帮助。

标签: cunit-testingcmakeunity-test-framework

解决方案


setUp只需添加名为and的空函数teadDownUnityGettingStartedGuide


推荐阅读