GTest installed with Conan: undefined reference

≯℡__Kan透↙ 提交于 2019-11-30 22:13:52

I found an answer to my question:

The problem is that conan does download/compile gtest binaries by default with libstdc++ even if my compiler (gcc 6.3) uses libstdc++11 by default. Thus there is a mismatch between libstdc++ and libstdc++11.

To workaround this issue you have to explicit tell conan to compile with libstdc++11:

conan install .. --build missing -s compiler=gcc -s compiler.version=6.3 -s compiler.libcxx=libstdc++11

I ended up having to add self.options['gtest'].shared = True in the project's conanfile.py to get around this. Previously it was set to false for some windows-related reasons that became non-relevant.

Try changing to shared libraries for gtest/gmock if, like me, you saw that the default settings were already libstdc++11 so changing the conan install args was not sufficient.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!