gpt4 book ai didi

c++ - 错误 : LINK: fatal error LNK1561: entry point must be defined c++

转载 作者:行者123 更新时间:2023-11-28 05:23:01 29 4
gpt4 key购买 nike

尝试编译我的代码时出现以下错误:error LNK1561: entry point must be defined.

背景:我正在尝试运行 Win32 CONSOLE 应用程序并使用 Google 测试框架。

我有我的主要功能设置,我已经检查了我的 Linker 是否设置为 Console (/SUBSYSTEM:CONSOLE) 根据我在许多问题中的一些其他建议'已经看到。我不确定为什么它不喜欢我的主要功能,因为它被定义为入口点。

这是我的代码:

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."));
}

最佳答案

进一步阐述 Mihaylov 的帖子。

在 VS 中,更新项目的属性,确保您的项目No Entry Point 链接器属性设置为NO

项目属性页/链接器/高级/无入口点 = 否

Entry Point

接下来更新链接器子系统属性

项目属性页/Linker/System/SubSystem = Console(/SUBSYSTEM:CONSOLE)

Project Property Page

关于c++ - 错误 : LINK: fatal error LNK1561: entry point must be defined c++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41078597/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com