<legend id='Pd7N7'><style id='Pd7N7'><dir id='Pd7N7'><q id='Pd7N7'></q></dir></style></legend>

    <tfoot id='Pd7N7'></tfoot>
    <i id='Pd7N7'><tr id='Pd7N7'><dt id='Pd7N7'><q id='Pd7N7'><span id='Pd7N7'><b id='Pd7N7'><form id='Pd7N7'><ins id='Pd7N7'></ins><ul id='Pd7N7'></ul><sub id='Pd7N7'></sub></form><legend id='Pd7N7'></legend><bdo id='Pd7N7'><pre id='Pd7N7'><center id='Pd7N7'></center></pre></bdo></b><th id='Pd7N7'></th></span></q></dt></tr></i><div id='Pd7N7'><tfoot id='Pd7N7'></tfoot><dl id='Pd7N7'><fieldset id='Pd7N7'></fieldset></dl></div>

      <bdo id='Pd7N7'></bdo><ul id='Pd7N7'></ul>

    <small id='Pd7N7'></small><noframes id='Pd7N7'>

      CMake 在 Ubuntu 中找不到 GoogleTest 所需的库

      时间:2023-08-27
        1. <small id='73sml'></small><noframes id='73sml'>

            <tfoot id='73sml'></tfoot>

          1. <i id='73sml'><tr id='73sml'><dt id='73sml'><q id='73sml'><span id='73sml'><b id='73sml'><form id='73sml'><ins id='73sml'></ins><ul id='73sml'></ul><sub id='73sml'></sub></form><legend id='73sml'></legend><bdo id='73sml'><pre id='73sml'><center id='73sml'></center></pre></bdo></b><th id='73sml'></th></span></q></dt></tr></i><div id='73sml'><tfoot id='73sml'></tfoot><dl id='73sml'><fieldset id='73sml'></fieldset></dl></div>
            <legend id='73sml'><style id='73sml'><dir id='73sml'><q id='73sml'></q></dir></style></legend>

            • <bdo id='73sml'></bdo><ul id='73sml'></ul>
                <tbody id='73sml'></tbody>

                本文介绍了CMake 在 Ubuntu 中找不到 GoogleTest 所需的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                类似问题此处.

                这是我的 CMakeLists.txt:

                This is my CMakeLists.txt:

                cmake_minimum_required(VERSION 2.6)
                
                # Locate GTest
                find_package(GTest REQUIRED)
                include_directories(${GTEST_INCLUDE_DIRS})
                
                # Add test cpp file
                add_executable(foo foo.cpp)
                
                # Link test executable against gtest & gtest_main
                target_link_libraries(foo ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread)
                

                还有我的 foo.cpp:

                And my foo.cpp:

                #include <gtest/gtest.h>
                
                TEST(sample_test_case, sample_test)
                {
                    EXPECT_EQ(1, 1);
                }
                
                int main(int argc, char **argv)
                {
                    testing::InitGoogleTest(&argc, argv);
                    return RUN_ALL_TESTS();
                }
                

                现在,使用 g++ 编译器时一切正常.但是,在尝试使用 QNX 的编译器 ntox86-c++ 时,我遇到了这个问题:

                Now, all works fine when using the g++ compiler. However, when attempting to use QNX's compiler, ntox86-c++, I run into this problem:

                CMake 错误在/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:97 (MESSAGE):找不到 GTest(丢失:GTEST_LIBRARY GTEST_INCLUDE_DIRGTEST_MAIN_LIBRARY)

                CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:97 (MESSAGE): Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)

                我在 Ubuntu 上使用 ntox86-c++ 编译器、googletest 和 cmake-gui.

                I am on Ubuntu using the ntox86-c++ compiler, googletest, and cmake-gui.

                是什么?

                推荐答案

                Google test 可能没有正确安装(libgtest-dev 可能只安装需要编译的源文件).我遇到了同样的问题,我按照 http://www.eriksmistad.no/getting-started-with-google-test-on-ubuntu/

                Google test was probably not properly installed (libgtest-dev may install only source files that needed to be compiled). I had the same problem and I followed the instructions from http://www.eriksmistad.no/getting-started-with-google-test-on-ubuntu/

                sudo apt-get install libgtest-dev
                sudo apt-get install cmake # install cmake
                cd /usr/src/gtest
                sudo cmake CMakeLists.txt
                sudo make
                
                #copy or symlink libgtest.a and libgtest_main.a to your /usr/lib folder
                sudo cp *.a /usr/lib
                

                这对我有用.

                这篇关于CMake 在 Ubuntu 中找不到 GoogleTest 所需的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何让 CMake 基于 GCC 版本通过 std=c++14/c++1y 或 c++17/c++1z? 下一篇:使用 Google 协议缓冲区的 CMake

                相关文章

                <legend id='HSGbv'><style id='HSGbv'><dir id='HSGbv'><q id='HSGbv'></q></dir></style></legend>

                1. <i id='HSGbv'><tr id='HSGbv'><dt id='HSGbv'><q id='HSGbv'><span id='HSGbv'><b id='HSGbv'><form id='HSGbv'><ins id='HSGbv'></ins><ul id='HSGbv'></ul><sub id='HSGbv'></sub></form><legend id='HSGbv'></legend><bdo id='HSGbv'><pre id='HSGbv'><center id='HSGbv'></center></pre></bdo></b><th id='HSGbv'></th></span></q></dt></tr></i><div id='HSGbv'><tfoot id='HSGbv'></tfoot><dl id='HSGbv'><fieldset id='HSGbv'></fieldset></dl></div>

                  <small id='HSGbv'></small><noframes id='HSGbv'>

                    <bdo id='HSGbv'></bdo><ul id='HSGbv'></ul>
                    <tfoot id='HSGbv'></tfoot>