首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

应用ftplib时出现_DefaultNetbuf多个多重定义

2012-11-06 
使用ftplib时出现_DefaultNetbuf多个多重定义我在file1.h中包含了file2.h,而在file2.h中包含了ftplib.h,这

使用ftplib时出现_DefaultNetbuf多个多重定义
我在file1.h中包含了file2.h,而在file2.h中包含了ftplib.h,这时就出现

1>Frame.obj : error LNK2005: _DefaultNetbuf 已经在 App.obj 中定义
1> 正在创建库 ..\bin\UpdateClient.lib 和对象 ..\bin\UpdateClient.exp
1>..\bin\UpdateClient.exe : fatal error LNK1169: 找到一个或多个多重定义的符号

ftplib.h里关于DefaultNetbuf的定义是这样的

#if !defined(__FTPLIB_H)
#define __FTPLIB_H
...

#ifdef __cplusplus
extern "C" {
#endif
typedef struct NetBuf netbuf;
typedef int (*FtpCallback)(netbuf *nControl, int xfered, void *arg);
/* v1 compatibility stuff */
#if !defined(_FTPLIB_NO_COMPAT)
netbuf *DefaultNetbuf;

#endif /* (_FTPLIB_NO_COMPAT) */
/* end v1 compatibility stuff */
...
#endif /* __FTPLIB_H */



我试了下把
#if !defined(_FTPLIB_NO_COMPAT)
netbuf *DefaultNetbuf;

改成
#if !defined(_FTPLIB_NO_COMPAT)
#define _FTPLIB_NO_COMPAT
netbuf *DefaultNetbuf;
还是出错...,在网上只找到个英文的相关问题说明,不过没有看明白。。。
http://www.experts-exchange.com/Programming/Languages/CPP/Q_20322803.html

[解决办法]
项目->属性->链接器->命令行->附加选项中加 /force
试下
[解决办法]

探讨
to hairetz :
谢啦,成功了,不过原理是啥啊,为啥会出现我那个错误,又为啥加个/force就好了咧?
能具体说下不,我在网上没有找到关于/force的说明

热点排行
Bad Request.