我想在我的项目中使用GMock。首先我编译了GMock和GTest。我的行动顺序(我使用Linux):
My project
具有以下结构:构建, inc , src 和 lib 目录。在 build 目录中,我运行cmake ..并make。在 inc 目录中,我放置了来自GIT / googletest / googlemock / include /和GIT / googletest / googletest / include /的所有标题。在 lib 中,dir只放置libgmock.a。在 src - 我项目的来源。
我的CMakeLists.txt
包含:
project(blockchain)
cmake_minimum_required(VERSION 2.6)
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR})
file(GLOB CPPS "*.cpp")
include_directories("../inc/")
link_directories("../lib/")
add_definitions(-Wall -O2 -std=c++11)
add_executable(${PROJECT_NAME} ${CPPS})
target_link_libraries(blockchain gmock)
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
当我尝试制作我的项目(在构建目录中键入cmake .. && make
)时,我收到链接错误:
CMakeFiles / blockchain.dir / main.cpp.o:在函数main': main.cpp :(。text.startup + 0x13):未定义的引用 totesting ::单元测试::的GetInstance()' main.cpp :(。text.startup + 0x1b):对测试的未定义引用:: UnitTest :: Run()' ../lib/libgmock.a(gmock-all.cc.o):在 functiontesting ::内部:: scoped_ptr的
:: reset(std :: __ cxx11 :: basic_stringstream)[clone .part.81] [clone .constprop.367]': gmock-all.cc:(.text+0x21a):对tests :: internal :: IsTrue(bool)'的未定义引用../lib/libgmock.a(gmock-all.cc.o):在 functiontesting :: internal :: MutexBase :: AssertHeld()const [clone .constprop.368]&#39 ;: gmock-all.cc:(.text+0x274):对tests :: internal :: IsTrue(bool)'的未定义引用gmock-all.cc :(. text + 0x2b2):未定义 参考 totesting ::内部:: GTestLog :: GTestLog(测试::内部:: GTestLogSeverity, char const,int)' gmock-all.cc:(.text+0x2fd):对tests :: internal :: GTestLog :: ~GTestLog()'的未定义引用gmock-all.cc:(.text+0x312): undefined reference totesting :: internal :: GTestLog :: ~GTestLog()' ../lib/libgmock.a(gmock-all.cc.o):在函数test :: internal :: Expect(bool,char const *,int, 的std :: __ cxx11 :: basic_string的, std :: allocator> const&)[clone .part.51]': gmock-all.cc:(.text+0x910):未定义的引用 totesting ::消息::消息()' gmock-all.cc:(.text+0x926):对tests :: internal :: AssertHelper :: AssertHelper的未定义引用(testing :: TestPartResult :: Type, char const *,int,char const *)' gmock-all.cc:(.text+0x931):未定义 参考 totesting :: internal :: AssertHelper :: operator =(testing :: Message const&) 常量' gmock-all.cc:(.text+0x939):对tests :: internal :: AssertHelper :: ~AssertHelper()'的未定义引用 gmock-all.cc:(.text+0x94b):未定义的引用 totesting ::内部:: IsTrue运算(布尔)'
还有很多其他人将错误联系起来。我做错了什么?
答案 0 :(得分:0)
exports.findManager = function (req, res) {
// Find all registration details of a user
Registrations.
find({ requester_manager_id: req.params.managerId }).
exec(function (err, registrationdetails) {
if (err) {
logger.error("Error while retrieving registration details: " + err)
res.status(500).send({ message: "Some error occurred while retrieving registration." });
} else {
logger.info("Successfully retrieved the registration details." + registrationdetails)
res.send(registrationdetails);
}
});
取决于 augeas { "bash_profile-${user}-${name}":
incl => "/home/${user}/.bash_profile",
lens => 'Shellvars.lns',
changes => [
"set ${variable_name} '\"${literal_value}\"'",
"set ${variable_name}/export ''",
],
}
。你添加了前者,但不是后者。