| 网站首页 | 业界新闻 | 群组 | 人才 | 技术文章 | 下载频道 | 博客 | 代码贴 | 编程论坛
共有 841 人关注过本帖
标题:执行 link.exe 时出错(贴源码)
只看楼主 收藏
xp3978052
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2017-6-8
  问题点数:0  回复次数:1   
执行 link.exe 时出错(贴源码)
#include <iostream>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <afxwin.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glaux.h>
#include <afx.h>
using namespace std;

//声明绘图函数
void myinit(void);//设置视口
void DrawMyObjects(void);//画点和线
void CALLBACK myReshape(GLsizei w,GLsizei h);//窗口改变后刷新
void CALLBACK display(void);
typedef struct Point
{    double x;
    double y;
    int num;          //记录原始点号
} Point;
int iTotalNum;         //点集中总点数
Point *que;           // 保存凸包结点,que为一个栈
Point *p;             //存储平面点集
int top;              // 记录栈顶位置
//读取点坐标
void ReadData()
{    ifstream in("D:\\t.dat");
    in >> iTotalNum;
    p = new Point[iTotalNum];    //循环读入平面点坐标数据    que = new Point[iTotalNum];
    double tt;
    int i;
    for (i=0; i<iTotalNum; ++i)
    {    int j = i+1;
        in >> j >> p[i].x >> p[i].y >> tt;
        p[i].num = i+1;   
}    in.close();    //关闭文件   
}
double dis(Point a, Point b)    // 求a, b两点距离
{    double distance;
    distance = sqrt(((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y)));
    return distance;  }
// 求P1P0与P2P0的叉积
//叉积,如果l>0,则说明直线P0P2在P0P1的逆时针方向
//判断左转,l>0,就做左转
double left(Point p2,Point p1, Point p0)
{    double l;
    l = (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
    return l;   }
// 用GrahamScan求凸包
void GrahamScan(int n)  
 {    Point tmp;
    int k = 0;
    int i;
    //[1]找出y值(y值相同时找x最小)最小的点作为起始点P0
    for(i=1; i<n; ++i)
        if((p[i].y < p[k].y) || ((p[i].y==p[k].y) && (p[i].x<p[k].x)))
            k = i;
    tmp  = p[0];    p[0] = p[k];     p[k] = tmp;
    // [2] 按极角大小逆时针排序,大于0时,p2在p1上面
    for( i=1; i<n; ++i)
    {    k = i;
        for(int j=i+1; j<n; ++j)
        {    if((left(p[j], p[k], p[0]) < 0) //j在k下面时才要互换
    || (left(p[j], p[k], p[0])==0 && dis(p[0], p[j])<dis(p[0], p[k])))
                k = j;  }
        tmp = p[i];        p[i] = p[k];        p[k] = tmp;     }
cout<<"按极角大小逆时针排序结果:"<<endl;
cout<<"起始点号:"<<"NO."<<p[0].num<<endl;
for( i=1; i<n; i++)
{     cout<<"第"<<i<<"个点:"<<"NO."<<p[i].num<<"\t";
}    cout<<endl;
    // [3] 把极角最小的0, 1, 2三点存入栈中
    for(i = 0; i <= 2; ++i)
        que[i] = p[i];
    top = 2;
    // [4] 从第3点开始判断左转,直到最后,若不左转则退栈
    for(i=3; i<n; i++)
    {        while((left(p[i],que[top],que[top-1]))<=0)   
//<0时不做左转,退栈
             top--;      que[++top]=p[i];    }
    top++;
    //显示结果
    cout<<endl;
    cout<<"构成凸包点坐标:"<<endl;   
    for(i=0; i<top; i++)
    {        cout<<i+1<<":  "<<"NO."<<p[i].num<<"\t"<<"坐标:"<<setprecision(10)<<que[i].x<<"  "<<setprecision(10)<<que[i].y<<endl;    }  
}
//GL绘图
void myinit(void)
{    glClearColor(1.0,1.0,0.0,0.0);
    glClear(GL_COLOR_BUFFER_BIT);
    glShadeModel(GL_FLAT);  }
void CALLBACK myReshape(GLsizei w,GLsizei h)
{    glViewport(0,0,w,h);
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
   if(w<=h)    //glOrtho(左,右,下,上,近,远)
       glOrtho(0.0,800.0,0.0*(GLfloat)h/(GLfloat)w,
                 600.0*(GLfloat)h/(GLfloat)w,-50.0,50.0);

   glOrtho(0.0*(GLfloat)w/(GLfloat)h,                 800.0*(GLfloat)w/(GLfloat)h,0.0,600.0,-50.0,50.0);
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();   
}
void CALLBACK display(void)
{    glClearColor(1.0,1.0,0.0,0.0);
    glClear(GL_COLOR_BUFFER_BIT);
    DrawMyObjects(); //画图函数
    glFlush();   }
void DrawMyObjects(void)
{   glBegin(GL_POINTS);     //画点
   glColor3f(1.0,0.0,0.0);
   for(int i=0; i<iTotalNum; i++)
    {       glVertex2d(p[i].x-492050,p[i].y-2639990);
}   glEnd();
  glBegin(GL_LINE_LOOP);     //画线
  for(i=0; i<top; i++)
    {   glVertex2d(que[i].x-492050,que[i].y-2639990);
    }   glEnd();
  glBegin(GL_TRIANGLES);      //凸包点三角号加重处理
  glColor3f(0.5,0.5,0.5);
  for(i =0; i<top; i++)
    {    glVertex2d(que[i].x-7830+0.4,que[i].y-7520-0.36);
             glVertex2d(que[i].x-7830,que[i].y-7520+0.46);
             glVertex2d(que[i].x-7830-0.4,que[i].y-7520-0.36);         }     glEnd();  
}
int main()
{    ReadData();
    GrahamScan(iTotalNum);
    auxInitDisplayMode(AUX_SINGLE|AUX_RGBA);
    auxInitPosition(80,80,910,640 );
     auxInitWindow("凸包示意图");
     myinit();
     auxReshapeFunc(myReshape);
     auxMainLoop(display);     
     _sleep(6000);     
     return 0;  
}


--------------------Configuration: 1111 - Win32 Debug--------------------
Linking...
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in libcpd.lib(delop.obj)
1111.obj : error LNK2001: unresolved external symbol __imp__glShadeModel@4
1111.obj : error LNK2001: unresolved external symbol __imp__glClear@4
1111.obj : error LNK2001: unresolved external symbol __imp__glClearColor@16
1111.obj : error LNK2001: unresolved external symbol __imp__glOrtho@48
1111.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
1111.obj : error LNK2001: unresolved external symbol __imp__glMatrixMode@4
1111.obj : error LNK2001: unresolved external symbol __imp__glViewport@16
1111.obj : error LNK2001: unresolved external symbol __imp__glFlush@0
1111.obj : error LNK2001: unresolved external symbol __imp__glEnd@0
1111.obj : error LNK2001: unresolved external symbol __imp__glVertex2d@16
1111.obj : error LNK2001: unresolved external symbol __imp__glColor3f@12
1111.obj : error LNK2001: unresolved external symbol __imp__glBegin@4
1111.obj : error LNK2001: unresolved external symbol _auxMainLoop@4
1111.obj : error LNK2001: unresolved external symbol _auxReshapeFunc@4
1111.obj : error LNK2001: unresolved external symbol _auxInitWindowA@4
1111.obj : error LNK2001: unresolved external symbol _auxInitPosition@16
1111.obj : error LNK2001: unresolved external symbol _auxInitDisplayMode@4
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/1111.exe : fatal error LNK1120: 19 unresolved externals
执行 link.exe 时出错.

1111.exe - 1 error(s), 0 warning(s)
搜索更多相关主题的帖子: display  include  double  记录  
2017-06-08 21:21
农民工
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:21
帖 子:109
专家分:639
注 册:2015-8-22
  得分:0 
楼主缺少导入lib文件吧
2017-09-21 14:29







关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.061680 second(s), 8 queries.
Copyright©2004-2018, BCCN.NET, All Rights Reserved