【发布时间】:2016-12-10 18:04:13
【问题描述】:
尝试编译代码时出现以下错误:error LNK1561: entry point must be defined.
背景:我正在尝试运行 Win32 CONSOLE 应用程序并使用 Google Tests 框架。
我有我的主要功能设置,我已经检查了我的Linker 设置为Console (/SUBSYSTEM:CONSOLE) 在我见过的许多问题中的其他一些建议。我不确定它为什么不喜欢我的 main 函数,因为它被定义为入口点。
这是我的代码:
bob.h
#ifndef BOB_BOB_H
#define BOB_BOB_H
#include <string>
using namespace std;
namespace bob {
string hey(const string&);
}
#endif
bob.cpp
#include "bob.h"
using namespace std;
namespace bob {
string hey(const string& theString)
{
return "Whatever."
}
}
bob_tests.cpp
// bob_tests.cpp : Defines the entry point for the console application
//
#include "bob.h"
#include <gtest/gtest.h>
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
TEST(Bob, stating_something)
{
EXPECT_STREQ("Whatever." bob::hey("Tom-ay-to, tom-aaaah-to."));
}
【问题讨论】:
标签: c++ googletest