我第一次安装了 MS VS VC++,以便开始使用 GLFW 库编写 OpenGL。我在 http://shawndeprey.blogspot.com/2012/02/setting-up-glfw-in-visual-studio-2010.html 上遵循有关如何安装它的说明。 然后我写了这个简单的程序,只是为了测试它,它确实在 Eclipse 上工作:
#include <stdlib.h>
#include <GL/glfw.h>
using namespace std;
int main()
{
int running = GL_TRUE;
if (!glfwInit()) {
exit(EXIT_FAILURE);
}
if (!glfwOpenWindow(300, 300, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)) {
glfwTerminate();
exit(EXIT_FAILURE);
}
while (running) {
// glClear( GL_COLOR_BUFFER_BIT );
glfwSwapBuffers();
running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED);
}
glfwTerminate();
exit(EXIT_SUCCESS);
return 0;
}
但后来我得到了这个可怕的错误:
------ Build started: Project: first1, Configuration: Debug Win32 ------
LINK : fatal error LNK1561: entry point must be defined
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我知道,我在互联网上四处查看,我发现的唯一解决方案是“它需要 main()
函数才能工作”。我显然有它,就在那里,但它仍然给我同样的 fatal error :(
如果能得到有关如何修复它的回复,那就太好了。安装过程中可能有我的缺陷或其他什么。
最佳答案
这是控制台程序项目还是 Windows 项目?我问是因为对于 Win32 和类似项目,入口点是 WinMain()
。
- 右键单击左侧的项目(不是解决方案)。
- 然后点击属性 -> 配置属性 -> 链接器 -> 系统
如果它显示 Subsystem Windows
你的入口点应该是 WinMain(),即
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd)
{
your code here ...
}
另外,说到评论。这是编译(或更准确地说是链接)错误,而不是运行时错误。当你开始调试时,编译器需要制作一个完整的程序(不仅仅是编译你的模块),这就是错误发生的时候。
它甚至没有达到加载和运行的目的。
关于c++ - 链接 : fatal error LNK1561: entry point must be defined ERROR IN VC++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17070367/