- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试对我的应用程序进行一些 Google 测试,但我在 OpenCV
和 GTest
之间遇到了一些冲突:
/usr/lib/gcc/i686-linux-gnu/4.6/../../../../lib/libgtest.a(gtest-all.cc.o): In function `testing::internal::GTestLog::GTestLog(testing::internal::GTestLogSeverity, char const*, int)':
gtest-all.cc:(.text+0xdd84): multiple definition of `testing::internal::GTestLog::GTestLog(testing::internal::GTestLogSeverity, char const*, int)'
/usr/local/lib/libopencv_ts.a(ts_gtest.cpp.o):ts_gtest.cpp:(.text._ZN7testing8internal8GTestLogC2ENS0_16GTestLogSeverityEPKci+0x0): first defined here
...
GTest
用于opencv_ts
库。有谁知道如何解决这些多重定义?
我认为如果我只添加我在 OpenCV
中使用的库,它将得到解决,但我不知道该怎么做。我试过:
target_link_libraries(${Exec8name}_test ${OpenCV}/opencv_core.so* ... )
target_link_libraries(${Exec8name}_test ${OpenCV_LIBS}/opencv_core.so* ... )
target_link_libraries(${Exec8name}_test ${OpenCV_LIBS_DIR}/opencv_core.so* ... )
等,但我只收到未找到的错误或No rule to make target
我试图删除两者之一,但出现错误
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
...
这是我的 CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
option(test "Build all tests." OFF)
set(EXECUTABLE_NAME MyProj)
project(${EXECUTABLE_NAME})
set(CMAKE_CXX_FLAGS "-g -Wall")
include_directories( src/main/cpp
${Boost_INCLUDE_DIRS}
)
find_package(OpenCV REQUIRED)
find_package(Boost REQUIRED COMPONENTS filesystem
system
regex
program_options)
add_executable(${EXECUTABLE_NAME}_Sol2
src/main/cpp/main.cpp
src/main/cpp/solution2/MySol2.hpp
src/main/cpp/solution2/MySol2.cpp
)
target_link_libraries(${EXECUTABLE_NAME}_Sol2 ${OpenCV_LIBS}
${Boost_LIBRARIES}
)
if (test)
find_package(GTest REQUIRED)
enable_testing()
include_directories( ${GTEST_INCLUDE_DIRS} )
add_executable(${EXECUTABLE_NAME}_Sol2_test
src/test/cpp/test_Sol2.cpp
src/main/cpp/solution2/MySol2.hpp
src/main/cpp/solution2/MySol2.cpp
)
target_link_libraries(${EXECUTABLE_NAME}_Sol2_test ${OpenCV_LIBRARIES}
${Boost_LIBRARIES}
)
target_link_libraries(${EXECUTABLE_NAME}_Sol2_test ${GTEST_LIBRARIES}
pthread
)
add_test(${EXECUTABLE_NAME}_Sol2_test
${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE_NAME}_Sol2_test
)
endif()
谁能告诉我一些解决方法?
最佳答案
“opencv_ts”模块包含 gtest,因此您可以只包括所需的 OpenCV 模块,排除所有“ts”模块。例如:
find_package(OpenCV REQUIRED core imgproc highgui)
关于c++ - CMake 中的 OpenCV 和 Gtest 冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22486748/
我在尝试使用 cmake 构建项目时遇到错误。 我在我的电脑上手动下载并安装了 gtest(即/usr/include 中提供了 gtest 头文件)和/usr/lib 中的 gtest、gtest_
我在构建我的项目时遇到以下错误 C:\gtest\gtest-1.6.0\include\gtest/gtest-printers.h(327) : error C2220: warning trea
你好, 我目前正在研究 CMake,以便在工作中使用 ExternalProject_add。因为我想测试 googletest,所以我尝试同时测试两者。我在编译单元测试代码时遇到问题。 所以我就按照
我一直在为这个问题苦苦挣扎一段时间:我在 Windows 10 下使用 CMake 和 GTest,但我得到一个 (Link target) -> LINK : fatal error LNK1104
如果内存不足,C++ 中的 new 关键字将抛出异常,但下面的代码会在 new 失败时尝试返回“NO_MEMORY”。这很糟糕,因为它会引发 std::bad_alloc 异常。 我正在写一个单元测试
我正在尝试运行一些Google测试,并且在每个测试装置中都有很多代码需要重复,因此我想使代码尽可能简短,我想使用的子类的SetUp方法Testing::test父类,但是TEST_F固定装置无法识别S
我正在尝试使用 gtest 类型参数化来确保我的类的基本功能。但是我被困在测试设置中。以下是示例: 我有两个名为 CatTest 和 DogTest 的类,以及一个名为 AnimalTest 的基类,
我想应用参数化测试并具有以下夹具: class MyTest: public ::testing::TestWithParam {...}; 我想设置两个参数化测试用例,其中一个小参数失败,但大参数成
如果我使用 g(oogle)Test,这些像 FRIEND_TEST(Test, Proc) 这样的小谷歌宏在我的代码中随处可见。是否有自动机制将它们从构建中排除,或者我真的必须用 #ifdefs 包
我有一个项目,我添加了一个 gtest 项目,然后将原始项目转换为 .lib 项目,并从第三个新项目调用其 main() 函数。这样,我就可以用项目 .exe 构建测试 .exe。除了,它不起作用。
注意:我知道这个问题以不同的方式被问到,但我无法根据我的限制解决它: 我正在使用谷歌测试版 1.7 使用平台工具集 V100 在 Visual Studio 2010 中编译 我正在为我创建的库编写
我的项目中有一个目录树: /project /build /src main.cpp student.cpp /include
在我们所知的 gtets 中,当控件找到 TEST 或 TEST_F 函数时,它会注册 测试用例 进入 gtest。但是按照我的要求,gtest注册完所有的测试用例之后我需要搜索 testcasena
我有一大套单元测试和一些集成测试是用谷歌测试框架或 gtest 实现的。 由于没有标记,我使用禁用约定将测试分成组或在它们前面加上 GROUPA_、GROUPB_ 等前缀。 这很好用。我可以过滤不同的
我想混合参数化测试和类型化测试。这是我的尝试: struct X {}; struct Y {}; template struct MyTestFixture: public ::testing::
我已阅读 this official document ,了解如何进行二进制比较和字符串比较。 ASSERT_EQ 和 ASSERT_STREQ 在数组比较情况下无法工作。 例如 li@li:~/po
我正在测试我的功能是否正确运行 bool Core::IsMeta(void) { return mProc->GetCode(mPC)->Meta; } 使用说明 EXPECT_EQ(true,
我想用 gtest 测试一个模板类。我在 Google Test manual 中阅读了有关 TYPED_TEST 的信息并查看了official example他们引用了,但我仍然无法全神贯注地获取
这是我的: /* Can't change 'base' struct. */ struct base { public: template void printVal() {
我想要等于 2 个对象,正好是卡片(使用 gtest 进行单元测试)。这是我的代码: #include "stdafx.h" #include #include class Card { p
我是一名优秀的程序员,十分优秀!