错误LNK2019:未解析的外部符号_main在函数___tmainCRTStartup中引用,但这次它不是Windows /控制台问题! [英] error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup, but this time it's NOT a Windows/Console problem!

查看:122
本文介绍了错误LNK2019:未解析的外部符号_main在函数___tmainCRTStartup中引用,但这次它不是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()方法:

The main() method:

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_main.h is included automatically from SDL.h, so you always get the nasty #define.

只要写:

#include <SDL.h>
#undef main

而且应该可以正常工作

这篇关于错误LNK2019:未解析的外部符号_main在函数___tmainCRTStartup中引用,但这次它不是Windows /控制台问题!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆