在DevC++中使用#pragma comment问题
OpenGL简单的例子,使用glut链接库,代码如下:
#include <math.h>#include "gl/glut.h"
//-lglut32 -lglu32 -lopengl32
//#pragma comment(lib,"glut32.lib")
//#pragma comment(lib,"glu32.lib")
//#pragma comment(lib,"opengl32.lib")
GLsizei winWidth = 600, winHeight = 600;
GLfloat xwcMin = 0.0, xwcMax = 225.0;
GLfloat ywcMin = 0.0, ywcMax = 225.0;
void init()
{
glClearColor(1.0, 1.0, 1.0, 1.0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(xwcMin, winWidth, ywcMin, winHeight);
}
/*执行函数*/
void displayFcn()
{
glFlush();
}
/*重绘函数,防止窗口变化*/
void winReshapeFcn(GLint newWidth, GLint newHeight)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(xwcMin, winWidth, ywcMin, winHeight);
glClear(GL_COLOR_BUFFER_BIT);
}
int main(int argc, char ** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(50, 50);
glutInitWindowSize(winWidth, winHeight);
glutCreateWindow("Geometric Transformation!");
init();
glutDisplayFunc(displayFcn);
glutReshapeFunc(winReshapeFcn);
glutMainLoop();
}
在编译器选项中添加链接参数-lglut32 -lglu32 -lopengl32可以正常运行,如图:
去掉链接参数,在代码中加入
#pragma comment(lib,"glut32.lib")#pragma comment(lib,"glu32.lib")
#pragma comment(lib,"opengl32.lib")
则未连接成功,如图:
回答:
去掉链接参数,在代码中加入#pragma comment(lib,"xxx.lib").
你把xxx.lib加入到你项目的目录下再调试。
以上是 在DevC++中使用#pragma comment问题 的全部内容, 来源链接: utcz.com/p/191184.html