头文件链接失败,不知道哪里出错

aa68454650 2010-08-13 12:41:01
#if !defined(AFX_NETDVRSDK_H__363D9034_1695_488A_B57F_949BD9F5CA79__INCLUDED_)
#define AFX_NETDVRSDK_H__363D9034_1695_488A_B57F_949BD9F5CA79__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#ifdef __cplusplus
extern "C"{
#endif

.....


/* ========================== structure for client's login information ============================= */
struct NETDVR_loginInfo_t
{
char username[12]; //username for login
char loginpass[12]; //password for login
char macAddr[18]; //client mac address
unsigned int ipAddr; //client ip address
};
/* ========================== structure for client's login information ============================= */
struct NETDVR_loginPass_t
{
char name[12]; //username for login
char oldpass[12]; //password for login
char newpass[12]; //client mac address
char confirm[12];

};


............


int NETDVR_loginPass(int Handle,const struct NETDVR_loginPass_t *p_para); //修改密码函数
int NETDVR_loginServer(int Handle, const struct NETDVR_loginInfo_t *p_para);

.....
/* ========================== 一下是编写的程序 ============================= */

/* ========================== 定义 ============================= */
#if !defined(AFX_DEMODLG_H__87832FF9_A629_4485_ADBC_19686B6B7FCA__INCLUDED_)
#define AFX_DEMODLG_H__87832FF9_A629_4485_ADBC_19686B6B7FCA__INCLUDED_
#include"netdvr.h"
#include"TLFileLib.h"

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

/////////////////////////////////////////////////////////////////////////////
// CDemoDlg dialog
#define MAX_PLAYWND 4
class CDemoDlg : public CDialog
{
// Construction
public:
CDemoDlg(CWnd* pParent = NULL); // standard constructor

// Dialog Data
//{{AFX_DATA(CDemoDlg)
enum { IDD = IDD_DEMO_DIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDemoDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
HICON m_hIcon;
int m_hDvr;
// Generated message map functions
//{{AFX_MSG(CDemoDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnBTlogin();
afx_msg void OnOut();
afx_msg void OnEditpas();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
NETDVR_DeviceInfo_t m_devinfo;
};

#endif // !defined(AFX_DEMODLG_H__87832FF9_A629_4485_ADBC_19686B6B7FCA__INCLUDED_)



/* ========================== 实现 ============================= */
void CDemoDlg::OnBTlogin()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);

char addbuf[80] ;
memset(addbuf,0,sizeof(80));
GetDlgItem(IDC_ServerAddr)->GetWindowText(addbuf, 80);

DWORD serverip = inet_addr(addbuf); //绑定IP地址

//CString strPort;
CString strPort;
GetDlgItem(IDC_ServerPort)->GetWindowText(strPort);
//WORD port = atoi(strPort);
int port=atoi(strPort); //绑定端口号
int ret = NETDVR_createDVR(&m_hDvr, serverip, port);
if (NETDVR_SUCCESS != ret)
{
CString szErr;
szErr.Format("open failed! ret = %d",ret);
AfxMessageBox(szErr);
return;
}
struct NETDVR_loginInfo_t logininfo;
memset(&logininfo, 0, sizeof(struct NETDVR_loginInfo_t));
GetDlgItem(IDC_UserID)->GetWindowText(logininfo.username,sizeof(logininfo.username));
GetDlgItem(IDC_UserPW)->GetWindowText(logininfo.username,sizeof(logininfo.username));

ret=NETDVR_loginServer(m_hDvr, &logininfo);
if (NETDVR_SUCCESS==ret)
{
AfxMessageBox("登陆成功");
}
else
{
CString szErr;
szErr.Format("open failed! ret = %d",ret);
AfxMessageBox(szErr);
return;
}
memset(&m_devinfo, 0, sizeof(m_devinfo));
ret = NETDVR_GetDeviceInfo(m_hDvr, &m_devinfo);


CString info;
in_addr in;
in.s_addr = m_devinfo.deviceIP;
info.Format("IP = %s\nPort = %d\ndevicename:%s\nmode:%s\nchnnum:%d\naudio:%d\nsubstream:%d\nplayback:%d\nalarmin:%d\nalarmout:%d\nhdd:%d\n",
inet_ntoa(in),
m_devinfo.devicePort,
m_devinfo.device_name,
m_devinfo.device_mode,
m_devinfo.maxChnNum,
m_devinfo.maxAudioNum,
m_devinfo.maxSubstreamNum,
m_devinfo.maxPlaybackNum,
m_devinfo.maxAlarmInNum,
m_devinfo.maxAlarmOutNum,
m_devinfo.maxHddNum);
/* for (int i=0; i<MAX_PLAYWND; i++)
{
BOOL bret = m_ddraw[i].CreateDDrawObj(YV12,
GetDlgItem(IDC_PLAYWND1+i)->GetSafeHwnd(),
704,
576);
}*/

GetDlgItem(IDC_ServerAddr)->EnableWindow(FALSE);
GetDlgItem(IDC_ServerPort)->EnableWindow(FALSE);
GetDlgItem(IDC_UserID)->EnableWindow(FALSE);
GetDlgItem(IDC_UserPW)->EnableWindow(FALSE);
GetDlgItem(IDC_BTlogin)->EnableWindow(FALSE);

}

void CDemoDlg::OnOut()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);

int ret=NETDVR_destroyDVR(m_hDvr);
if (NETDVR_SUCCESS != ret)
{
AfxMessageBox("close failed!");
return;
}
m_hDvr=0;
InvalidateRect(NULL);
GetDlgItem(IDC_OUT)->EnableWindow(FALSE);
GetDlgItem(IDC_ServerAddr)->EnableWindow(TRUE);
GetDlgItem(IDC_ServerPort)->EnableWindow(TRUE);
GetDlgItem(IDC_UserID)->EnableWindow(TRUE);
GetDlgItem(IDC_UserPW)->EnableWindow(TRUE);
GetDlgItem(IDC_BTlogin)->EnableWindow(TRUE);
}

void CDemoDlg::OnEditpas()
{
// TODO: Add your control notification handler code here
struct NETDVR_loginPass_t logininfo;
GetDlgItem(IDC_NewID)->GetWindowText(logininfo.name,sizeof(logininfo.name));
GetDlgItem(IDC_OldPass)->GetWindowText(logininfo.oldpass,sizeof(logininfo.oldpass));
GetDlgItem(IDC_NewPass)->GetWindowText(logininfo.newpass,sizeof(logininfo.newpass));
GetDlgItem(IDC_PasCon)->GetWindowText(logininfo.confirm,sizeof(logininfo.confirm));

int ret=NETDVR_loginPass(m_hDvr,&logininfo);
if (ret!=NETDVR_SUCCESS)
{
AfxMessageBox("修改失败");
return ;
}
else
{
AfxMessageBox("修改成功");
}
}





以上代码经过调试后出现以下链接错误信息
--------------------Configuration: demo - Win32 Debug--------------------
Compiling...
demoDlg.cpp
Linking...
demoDlg.obj : error LNK2001: unresolved external symbol _NETDVR_loginPass
Debug/demo.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

demo.exe - 2 error(s), 0 warning(s)
我个人认为是连接的DLL问题,各位大侠认为呢,对方说是没这个函数的接口,那我应该怎样定义这个函数的底层接口呢,或者各位大侠加我QQ:68454650 本人会发DLL给各位大侠测试,请各位帮们解决


...全文
97 点赞 收藏 5
写回复
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
cynthiamoonbeen 2010-08-14
个人认为链接不了,基本有2中情况,一是楼上的说法,链接dll时链接lib出错,还有就是最简单的一种,任务管理器结束 进程,再重新开开看看,或许就好用了。
Ctrl+Alt+Delete结束就好了。
如果还是链接不上,建议你在好好看看程序... ...
回复
aa68454650 2010-08-13
头文件红色部分为本人添加的函数
回复
山伟 2010-08-13
int NETDVR_loginPass(int Handle,const struct NETDVR_loginPass_t *p_para); //修改密码函数

---------
这个函数只有定义,没有函数体。
如果是调用DLL,请用#pragma comment( LIB,"XXX.LIB") 的方式引用相关的LIB文件
回复
没有找到函数体。
回复
wltg2001 2010-08-13
int NETDVR_loginPass(int Handle,const struct NETDVR_loginPass_t *p_para); //修改密码函数
========
你这个函数是在什么地方实现的呢?是你自己写的还是引用别的DLL中的函数呢?
如果不是你自己写的,那么你要用#pragma comment( LIB,"XXX.LIB") 的方式引用相关的LIB文件
回复
发动态
发帖子
VC/MFC
创建于2007-09-28

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
社区公告
暂无公告