error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup, but this time it#39;s NOT a Windows/Console problem!(错误 LNK2019:函数 ___tmainCRTStartup 中引用了未解析的外部符号 _main,但这一次不是 Windows/控制台问题!)
问题描述
所以,臭名昭著的错误又回来了.该项目抱怨它找不到 main() 方法(这就是错误的含义,对).
So, the infamous error is back. The project is complaining that it can't find the main() method (that's what the error means, right).
但是我确实有一个主项目,而且我的项目应该是一个控制台项目.它以前有效,所以我知道不是那样.
However I do have a main, and my project is a Console project, as it should be. It worked before, so I know it's not that.
此外,该项目的类和文件太多,我无法将它们全部发布,因此我会根据您的要求发布任何您需要的类.
Also, the project has too many classes and files for me to post them all, so I will post any classes you need by request.
这是 Visual Studio 2010 上的 C++、OpenGL 和 SDL 游戏.这不是任何库的问题,因为它在突然莫名其妙地显示此链接器错误之前运行良好.
It's a C++, OpenGL and SDL game on Visual Studio 2010. It's not a problem of any of the libraries, as it was working fine before it suddenly and inexplicably showed this linker error.
main() 方法:
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_ALPHA);
glutCreateWindow("Game");
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
g = Game();
glutInitWindowSize(g.getScreenWidth(), g.getScreenHeight());
//glutPositionWindow(1280, 50);
// Callbacks
glutDisplayFunc(handleRedraw);
glutReshapeFunc(handleResize);
glutMouseFunc(handleMouseClicks);
glutPassiveMotionFunc(handleMouseOvers);
glutKeyboardFunc(handleKeyboardEvents);
glutTimerFunc(50, moveItemToInventory, 0);
glutMainLoop();
return 0;
}
推荐答案
SDL_main.h 自动包含在 SDL.h 中,因此您总是会遇到讨厌的 #define.
SDL_main.h is included automatically from SDL.h, so you always get the nasty #define.
随便写:
#include <SDL.h>
#undef main
它应该可以正常工作
这篇关于错误 LNK2019:函数 ___tmainCRTStartup 中引用了未解析的外部符号 _main,但这一次不是 Windows/控制台问题!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:错误 LNK2019:函数 ___tmainCRTStartup 中引用了未解析的外部符号 _main,但这一次不是 Windows/控制台问题!
基础教程推荐
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- CString 到 char* 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
