在编译中遇到 defaultlib "MSVCRT" conflicts with use of other libs 怎么解决??急!!!

hummerking 2004-05-02 11:16:50

我的程序使用到了 postgresql 数据库的C接口函数,如果使用动态库libpq.dll程序编译没有任何问题,但是如果使用静态的libpq.lib,在编译中会出现以下错误
程序中MFC使用的也是静态连接。


Linking...
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _sprintf already defined in libcmtd.lib(sprintf.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _malloc already defined in libcmtd.lib(dbgheap.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _free already defined in libcmtd.lib(dbgheap.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _strncpy already defined in libcmtd.lib(strncpy.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __snprintf already defined in libcmtd.lib(snprintf.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _realloc already defined in libcmtd.lib(dbgheap.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _tolower already defined in libcmtd.lib(tolower.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __isctype already defined in libcmtd.lib(isctype.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _strspn already defined in libcmtd.lib(strspn.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _strncmp already defined in libcmtd.lib(strncmp.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __errno already defined in libcmtd.lib(dosmap.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _strtoul already defined in libcmtd.lib(strtol.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _getenv already defined in libcmtd.lib(getenv.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _atoi already defined in libcmtd.lib(atox.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _memmove already defined in libcmtd.lib(memmove.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fclose already defined in libcmtd.lib(fclose.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fgets already defined in libcmtd.lib(fgets.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fopen already defined in libcmtd.lib(fopen.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fflush already defined in libcmtd.lib(fflush.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __vsnprintf already defined in libcmtd.lib(vsnprint.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _exit already defined in libcmtd.lib(crt0dat.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __strdup already defined in libcmtd.lib(strdup.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __stricmp already defined in libcmtd.lib(stricmp.obj)
LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library
Debug/dataman.exe : fatal error LNK1169: one or more multiply defined symbols found

用于是刚接触VC,请各位能帮帮小弟,谢了!!! 急!!!!
...全文
1988 14 点赞 打赏 收藏 举报
写回复
14 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
hopen 2004-06-18
错了,错了,怎么把握自己的lib写进去了,应该是:

因为MSVCRT.lib(MSVCRT.dll)是Dll不能Ignore 它,应该Ignore的是libcmtd.lib
在Project->settings->Link中Category中选择“input"选项
在Ignore libraries 中将与MSVCRT.lib 冲突的libcmtd.lib
写入就行了或者像aspvbjava(最近比较郁闷)所说的project-->setting-->link-->project options里面,不是加入/NODEFAULTLIB:MSVCRT.lib 而是加入/NODEFAULTLIB:libcmtd.lib

  • 打赏
  • 举报
回复
hopen 2004-06-18
我今天也遇到了类型的问题。Ignore all default libraries然后手动添加是一种办法但是比较繁琐。
因为MSVCRT.lib(MSVCRT.dll)是Dll不能Ignore 它,应该Ignore的是libcmtd.lib
在Project->settings->Link中Category中选择“input"选项
在Ignore libraries 中将LIBCD.lib冲突的lib写入就行了libcmtd.lib

或者像aspvbjava(最近比较郁闷)所说的project-->setting-->link-->project options里面,不是加入/NODEFAULTLIB:MSVCRT.lib 而是加入/NODEFAULTLIB:libcmtd.lib


  • 打赏
  • 举报
回复
robert9999 2004-06-16
我也遇到类似问题,不知道什么原因!
  • 打赏
  • 举报
回复
hummerking 2004-05-08
如果 Ignore all default libraries ,应该手动添加那些库呢???不好意思,刚接触VC搞不大清楚。
  • 打赏
  • 举报
回复
PiggyXP 2004-05-07
啊,Ignore all default libraries然后手动添加不成末?
那不知道了,关注,友情up一下
  • 打赏
  • 举报
回复
hummerking 2004-05-04
自己在up一下
  • 打赏
  • 举报
回复
runall 2004-05-04
帮你up一下
  • 打赏
  • 举报
回复
aspvbjava 2004-05-03
还有可能是你的库路径的设置顺序,你把你的库路径设置上下顺序调节一下
  • 打赏
  • 举报
回复
hummerking 2004-05-03
如果Ignore all default libraries那更不成了。。。自己手动添加需要的库??一会儿试一下吧。
  • 打赏
  • 举报
回复
hummerking 2004-05-03
楼上兄弟说的不成啊。。。

LINK : warning LNK4049: locally defined symbol "_sprintf" imported
LINK : warning LNK4049: locally defined symbol "_malloc" imported
LINK : warning LNK4049: locally defined symbol "_free" imported
LINK : warning LNK4049: locally defined symbol "_strncpy" imported
LINK : warning LNK4049: locally defined symbol "__snprintf" imported
LINK : warning LNK4049: locally defined symbol "_realloc" imported
LINK : warning LNK4049: locally defined symbol "__pctype" imported
LINK : warning LNK4049: locally defined symbol "___mb_cur_max" imported
LINK : warning LNK4049: locally defined symbol "_tolower" imported
LINK : warning LNK4049: locally defined symbol "__isctype" imported
LINK : warning LNK4049: locally defined symbol "_strspn" imported
LINK : warning LNK4049: locally defined symbol "_strncmp" imported
LINK : warning LNK4049: locally defined symbol "__errno" imported
LINK : warning LNK4049: locally defined symbol "_strtoul" imported
LINK : warning LNK4049: locally defined symbol "_getenv" imported
LINK : warning LNK4049: locally defined symbol "_atoi" imported
LINK : warning LNK4049: locally defined symbol "_memmove" imported
LINK : warning LNK4049: locally defined symbol "_fclose" imported
LINK : warning LNK4049: locally defined symbol "_fgets" imported
LINK : warning LNK4049: locally defined symbol "_fopen" imported
LINK : warning LNK4049: locally defined symbol "_fflush" imported
LINK : warning LNK4049: locally defined symbol "__iob" imported
LINK : warning LNK4049: locally defined symbol "__vsnprintf" imported
LINK : warning LNK4049: locally defined symbol "_exit" imported
LINK : warning LNK4049: locally defined symbol "__strdup" imported
LINK : warning LNK4049: locally defined symbol "__stricmp" imported
libpq.lib(fe-exec.obj) : error LNK2001: unresolved external symbol __imp__strdup
libpq.lib(fe-connect.obj) : error LNK2001: unresolved external symbol __imp__strdup
OLDNAMES.lib(strdup.obi) : error LNK2001: unresolved external symbol __imp__strdup
libpq.lib(fe-connect.obj) : error LNK2001: unresolved external symbol __imp__stricmp
OLDNAMES.lib(stricmp.obi) : error LNK2001: unresolved external symbol __imp__stricmp
libpq.lib(fe-connect.obj) : error LNK2001: unresolved external symbol __imp__strtok
libpq.lib(fe-connect.obj) : error LNK2001: unresolved external symbol __imp__fprintf
libpq.lib(fe-misc.obj) : error LNK2001: unresolved external symbol __imp__fprintf
libpq.lib(dllist.obj) : error LNK2001: unresolved external symbol __imp__fprintf
libpq.lib(fe-auth.obj) : error LNK2001: unresolved external symbol __imp__perror
Debug/dataman.exe : fatal error LNK1120: 5 unresolved externals
  • 打赏
  • 举报
回复
SatanLi1982 2004-05-02
还有,可能是你的头文件包含有问题。
  • 打赏
  • 举报
回复
anothervip 2004-05-02
在project setting中的link tab下,选中ignore default lib。然后自己加要用的库。
  • 打赏
  • 举报
回复
SatanLi1982 2004-05-02
Project->settings->Link->Select Ignore all default libraries
  • 打赏
  • 举报
回复
aspvbjava 2004-05-02
project-->setting-->link-->project options里面,加入
/NODEFAULTLIB:MSVCRT.lib
  • 打赏
  • 举报
回复
相关推荐
发帖
VC/MFC
加入

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
帖子事件
创建了帖子
2004-05-02 11:16
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……