gtest installed with conan: undefined reference to `testing::internal::GetBoolAssertionFailureMessage`

前端 未结 1 2079
心在旅途
心在旅途 2021-01-15 08:02

I use cmake to build my project and conan to install Google Test as dependency:

conanfile.txt

[requires]
gtest/1.7.0@lasote/stable

         


        
相关标签:
1条回答
  • 2021-01-15 09:01

    The issue is that you are installing conan dependencies using the default settings (which is build type Release):

    $ conan install --build=missing
    # equivalent to
    $ conan install -s build_type=Release ... --build=missing
    

    The default settings can be seen in your conan.conf file

    Then, you are using cmake in a nix system with the default build type which is Debug, which is a single-conf environment (opposed to multi-configuration Debug/Release environments, as Visual Studio), so when you are doing:

    $ cmake .. && cmake --build .
    # equivalent to
    $ cmake .. -DCMAKE_BUILD_TYPE=Debug && cmake --build .
    

    The incompatibility of Debug/Release build leads to that unresolved issue. So the solution would be to use the same build type that matches your installed dependencies:

    $ cmake .. -DCMAKE_BUILD_TYPE=Release && cmake --build .
    

    If using multi-configuration environments like Visual Studio, the correct way would be:

    $ cmake .. && cmake --build . --config Release
    
    0 讨论(0)
提交回复
热议问题