我在windows和linux中使用clang 7来生成c++项目的覆盖率。在linux中,我可以简单地通过添加编译标志来成功地生成所有覆盖信息:
-fprofile-instr-generate -fcoverage-mapping但是在windows中,它会返回链接器错误,并且llvm-cov在llvm安装目录中也不存在。
所以我猜clang不支持windows中的代码覆盖?是这样的吗?
(如果没有,你能告诉我我在链接阶段遗漏了什么吗?)
PS:链接器错误来自:
lld-link.exe: error: duplicate symbol: __profn_??_GTestFactoryBase@internal@testing@@UEAAPEAXI@Z至:
lld-link.exe: error: undefined symbol: __llvm_profile_runtime
>>> referenced by src\app\CMakeFiles\app.dir\main.cpp.obj:(__llvm_profile_runtime_user)
lld-link.exe: error: undefined symbol: __llvm_profile_register_function
>>> referenced by src\app\CMakeFiles\app.dir\main.cpp.obj:(__llvm_profile_register_functions)
>>> referenced by src\app\CMakeFiles\app.dir\main.cpp.obj:(__llvm_profile_register_functions)注:我正在使用visual studio构建工具在windows中使用clang进行编译。
PS2:据我所知,我们还需要将"-fprofile-instr-generate“传递给链接器...但我不知道该怎么做...
谢谢
发布于 2019-02-14 17:06:56
在windows上,您应该使用clang-cl.exe和--coverage选项。这个链接将帮助你做到这一点...https://marco-c.github.io/2018/01/09/code-coverage-with-clang-on-windows.html
https://stackoverflow.com/questions/53570642
复制相似问题