我用OpenGL编的东西,编译没问题连接时出现两个错误,是什么原因呢?有没有什么办法解决呢?
原文件:// Console.cpp : Defines the entry point for the console application.#include "stdafx.h"#pragma warning(disable : 4305)
#include <windows.h>
//添加OpenGl头文件
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glaux.h>
//定义用户函数及回调函数
void myInit(void);
void CALLBACK myReshape(GLsizei w,GLsizei h);
void CALLBACK myDisplay(void);
void myInit(void)
{
glClearColor(0.0,0.0,0.0,0.0);//背景清除颜色
glShadeModel(GL_FLAT); //图形绘制模式
}
void CALLBACK myDisply(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor4f(0.2,0.6,1.0,1.0); //图形绘制颜色
glRotatef(60.0,1.0,1.0,1.0); //设置旋转
auxWireSphere(1.0); //绘制线框模式的球
glFlush(); //完成绘制
}
void CALLBACK myReshape(GLsizei w,GLsizei h)
{
glViewport(0,0,w,h); //设置窗口缩放时的视口变换
}
int main(int argc, char* argv[])
{
auxInitDisplayMode(AUX_SINGLE|AUX_RGBA);//初始化显示模式
auxInitPosition(0,0,400,400); //窗口显示位置
auxInitWindow("My First Console OpenGl Application");//窗口标题
myInit();
auxReshapeFunc(myReshape);
auxMainLoop(myDisplay);
return 0;
}
错误信息:
Linking...
console.obj : error LNK2001: unresolved external symbol "void __stdcall myDisplay(void)" (?myDisplay@@YGXXZ)
Debug/console.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.(console 是我建立的文件,整个文件主要用类来完成。)
原文件:// Console.cpp : Defines the entry point for the console application.#include "stdafx.h"#pragma warning(disable : 4305)
#include <windows.h>
//添加OpenGl头文件
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glaux.h>
//定义用户函数及回调函数
void myInit(void);
void CALLBACK myReshape(GLsizei w,GLsizei h);
void CALLBACK myDisplay(void);
void myInit(void)
{
glClearColor(0.0,0.0,0.0,0.0);//背景清除颜色
glShadeModel(GL_FLAT); //图形绘制模式
}
void CALLBACK myDisply(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor4f(0.2,0.6,1.0,1.0); //图形绘制颜色
glRotatef(60.0,1.0,1.0,1.0); //设置旋转
auxWireSphere(1.0); //绘制线框模式的球
glFlush(); //完成绘制
}
void CALLBACK myReshape(GLsizei w,GLsizei h)
{
glViewport(0,0,w,h); //设置窗口缩放时的视口变换
}
int main(int argc, char* argv[])
{
auxInitDisplayMode(AUX_SINGLE|AUX_RGBA);//初始化显示模式
auxInitPosition(0,0,400,400); //窗口显示位置
auxInitWindow("My First Console OpenGl Application");//窗口标题
myInit();
auxReshapeFunc(myReshape);
auxMainLoop(myDisplay);
return 0;
}
错误信息:
Linking...
console.obj : error LNK2001: unresolved external symbol "void __stdcall myDisplay(void)" (?myDisplay@@YGXXZ)
Debug/console.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.(console 是我建立的文件,整个文件主要用类来完成。)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor4f(0.2,0.6,1.0,1.0); //图形绘制颜色
glRotatef(60.0,1.0,1.0,1.0); //设置旋转
auxWireSphere(1.0); //绘制线框模式的球
glFlush(); //完成绘制
}
glu32.lib, glau.lib, OpenGL32.lib
上面写错了
还有一个glut32.lib,好像没用到