无法解析的外部符号

chentan19934 2017-07-22 10:42:20
自己定义的一个函数,进行移植的时候出现这个问题,在原程序中正常,移植后声明,定义不变,编译的时候报错
#ifndef OPENSERVER_H_INCLUDED
#define OPENSERVER_H_INCLUDED

void OpenSrve(void);

#endif // OPENSERVER_H_INCLUDED

#include<Winsock2.h>
#include<process.h>
#include<stdio.h>
#include<stdlib.h>
#include"ComInterface.h"
#include"ReceiveMessage.h"

void OpenSrv(void)
{
int iPort = DEFAULT_PORT;

WSADATA wsaData;

struct sockaddr_in ser;

if(WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
{
printf("Failed to load Winsock.\n");
return;
}

sSocket = socket(AF_INET, SOCK_DGRAM, 0);

if(sSocket == INVALID_SOCKET)
{
printf("socket()Failed:%d\n", WSAGetLastError());
return;
}

ser.sin_family = AF_INET;
ser.sin_port = htons(iPort);
ser.sin_addr.s_addr = htonl(INADDR_ANY);

if(bind(sSocket, (sockaddr*)&ser, sizeof(ser)) == SOCKET_ERROR)
{
printf("bind()Failed:%d\n", WSAGetLastError());
return;
}
else
{
printf("------------------------------\n");
printf("Server waiting\n");
printf("------------------------------\n");
}

_beginthread(RecvMsg, 1024 * 1024, (void*)sSocket);
}

#include "oglx.h"
#include <Winsock2.h>
#include <process.h>
#include "GL/glut.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sdy_events.h"
#include "specific.h"
#include "ComInterface.h"
#include "OpenServer.h"
#include "SendMessage.h"

int main(int argc, char *argv[])
{
/* Step 1: Initialize the GLUT library and negotiate a session with the
window system */
OpenSrv();
glutInit(&argc, argv);

/* Step 2: Set the initial display mode, which is used when creating
top-level windows, subwindows, and overlays to determine the
OpenGL display mode for the to-be-created window or overlay */
glutInitDisplayMode(GLUT_ALPHA | GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL);

/* Step 3: Set the initial window size in pixels */
glutInitWindowSize(getW(), getH());


/* Step 4: Create a top-level window. The name will be provided to the window
system as the window's name. Implicitly, the current window is set
to the newly created window. Each created window has a unique associated
OpenGL context. State changes to a window's associated OpenGL context
can be done immediately after the window is created. */
glutCreateWindow(getSpecName());


/* Step 5: Initialize all OGLX states and variables */
oglx_init();

/* Step 6: Initialize the SCADE Suite and/or Display application */
init_scene();

/* Step 7: Define the GLUT callbacks for display, window, keyboard,
mouse, etc. management */
glutDisplayFunc(display_callback);
glutReshapeFunc(reshape_callback);
glutKeyboardFunc(keyboard_callback);

glutMouseFunc(mouse);
glutPassiveMotionFunc(mousePassiveMotion);
glutMotionFunc(mouseMotion);

timer_callback(0);
//while(1)
//{
// distance+=distance;
//}
//

/* On Windows only, disable vertical synchronization (V-Sync) to avoid limiting FPS */
#ifdef _WIN32
{
typedef BOOL(APIENTRY * PFNWGLSWAPINTERVALFARPROC) (int);
PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC) wglGetProcAddress("wglSwapIntervalEXT");
if (wglSwapIntervalEXT) {
wglSwapIntervalEXT(0);
}
}
#endif

/* Final Step: Enter the GLUT event processing loop. Once called, this
routine will never return. It will call as necessary any callbacks
that have been registered. */



glutMainLoop();




return 0;
}
...全文
264 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
自信男孩 2017-07-23
  • 打赏
  • 举报
回复
注意下是不是函数名不对呢,OpenSrve和OpenSrv的区别。
xian_wwq 2017-07-23
  • 打赏
  • 举报
回复
无法解析是因为没有定义或者张冠李戴了
战在春秋 2017-07-23
  • 打赏
  • 举报
回复
引用
编译的时候报错
提问时最好能附上具体的错误信息,更利于定位。
void OpenSrve(void);  //和后来的函数名不一致,多了一个e
不确定是不是粘贴失误,如果这是最终版本,那肯定是要报错的。

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧