无法打开包括文件:“json.h”: No such file or directory

时间:2023-01-30 20:14:41
我引用了一个第三方json库, lib,及相应的.h文件也COPY到了当前项目中,编译时可就是提示:
无法打开包括文件:“json.h”: No such file or directory,
 VS2008中要怎样引用.h文件呢?百度了很多还是不行,真是搞不懂了,感叹C++入门真难!

请大家指点,谢谢.

头文件引用如下:
----------------------------------------------------
#pragma comment(lib, "json_vc71_libmtd.lib")
#include <afxwin.h>
#include <afx.h>
#include <afxinet.h>
#include <iostream>
# include <config.h>
#include <json.h>

14 个解决方案

#1


如果文件所在上当不是当前目录,需要将文件所在目录添加到项目属性中

另外:

#include <json.h>

改成

#include "json.h"

#2


引用 1 楼 paschen 的回复:
如果文件所在上当不是当前目录,需要将文件所在目录添加到项目属性中

另外:

#include <json.h>

改成

#include "json.h"


我的目录结构如下: 
F:\C++\excise\myExcise    (.cpp所在目录)
F:\C++\excise\myExcise\include     (json.h等h文件所在目录)
F:\C++\excise\myExcise\Debug\json    (json_vc71_libmtd.lib 文件所在目录)

改成 include "json.h" 还是不行,请指教,谢谢。
 java引用个jar包也没这么复杂。

#3


引用 2 楼 andylauxing 的回复:
Quote: 引用 1 楼 paschen 的回复:

如果文件所在上当不是当前目录,需要将文件所在目录添加到项目属性中

另外:

#include <json.h>

改成

#include "json.h"


我的目录结构如下: 
F:\C++\excise\myExcise    (.cpp所在目录)
F:\C++\excise\myExcise\include     (json.h等h文件所在目录)
F:\C++\excise\myExcise\Debug\json    (json_vc71_libmtd.lib 文件所在目录)

改成 include "json.h" 还是不行,请指教,谢谢。
 java引用个jar包也没这么复杂。


#include "F:\\C++\\excise\\myExcise\\Debug\\json.h"

#4



谢谢,兄台,.h可以了, 但又提示找不到.lib文件,错误提示如下:
fatal error LNK1104: 无法打开文件“json_vc71_libmtd.lib”

我的引用代码如下,难道这里也要加入路径??
#pragma comment(lib, "json_vc71_libmtd.lib")

#5


项目 -> 属性 - > 配置属性 -> C/C++ -> 常规附加包含目录
添加: ./ 


#6


右键项目--属性

.h文件这样做:
C/C++里的附加包含目录:F:\C++\excise\myExcise\Debug\

.lib这样做:
链接器--输入--附加依赖项添加上:json_vc71_libmtd.lib
链接器--常规--附加库目录添加上:F:\C++\excise\myExcise\Debug\json

#7


还是不行,错误如下:
1>------ 已启动生成: 项目: myExcise, 配置: Debug Win32 ------
1>正在编译..
1>正在链接...
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) 已经在 json_vc71_libmtd.lib(json_value.obj) 中定义

1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Lock(void)" (?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) 已经在 json_vc71_libmtd.lib(json_reader.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Unlock(void)" (?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) 已经在 json_vc71_libmtd.lib(json_reader.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) 已经在 json_vc71_libmtd.lib(json_value.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@ABV01@@Z) 已经在 json_vc71_libmtd.lib(json_value.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@ABV10@PBD@Z) 已经在 json_vc71_libmtd.lib(json_reader.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) 已经在 json_vc71_libmtd.lib(json_value.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::length(void)const " (?length@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) 已经在 json_vc71_libmtd.lib(json_value.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: bool __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::empty(void)const " (?empty@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE_NXZ) 已经在 json_vc71_libmtd.lib(json_reader.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator+=(char)" (??Y?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@D@Z) 已经在 json_vc71_libmtd.lib(json_reader.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: char const & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator[](unsigned int)const " (??A?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEABDI@Z) 已经在 json_vc71_libmtd.lib(json_writer.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::size(void)const " (?size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) 已经在 json_vc71_libmtd.lib(json_value.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::locale::facet * __thiscall std::locale::facet::_Decref(void)" (?_Decref@facet@locale@std@@QAEPAV123@XZ) 已经在 json_vc71_libmtd.lib(json_reader.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _printf 已经在 LIBCMTD.lib(printf.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _fclose 已经在 LIBCMTD.lib(fclose.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __mktime64 已经在 LIBCMTD.lib(mktime64.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _abort 已经在 LIBCMTD.lib(abort.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _malloc 已经在 LIBCMTD.lib(dbgmalloc.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _memcpy_s 已经在 LIBCMTD.lib(memcpy_s.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _isalpha 已经在 LIBCMTD.lib(_ctype.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _isdigit 已经在 LIBCMTD.lib(_ctype.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _isspace 已经在 LIBCMTD.lib(_ctype.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _ispunct 已经在 LIBCMTD.lib(_ctype.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _free 已经在 LIBCMTD.lib(dbgfree.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _calloc 已经在 LIBCMTD.lib(dbgcalloc.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __recalloc 已经在 LIBCMTD.lib(dbgheap.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _exit 已经在 LIBCMTD.lib(crt0dat.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strcpy_s 已经在 LIBCMTD.lib(strcpy_s.obj) 中定义
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) 已经在 LIBCMTD.lib(typinfo.obj) 中定义
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) 已经在 LIBCMTD.lib(typinfo.obj) 中定义
1>msvcrtd.lib(MSVCR90D.dll) : error LNK2005: __CrtDbgReportW 已经在 LIBCMTD.lib(dbgrptw.obj) 中定义
1>libcpmtd.lib(locale0.obj) : error LNK2005: "void __cdecl _AtModuleExit(void (__cdecl*)(void))" (?_AtModuleExit@@YAXP6AXXZ@Z) 已经在 msvcprt.lib(locale0_implib.obj) 中定义
1>libcpmtd.lib(locale0.obj) : error LNK2005: __Fac_tidy 已经在 msvcprt.lib(locale0_implib.obj) 中定义
1>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static void __cdecl std::locale::facet::facet_Register(class std::locale::facet *)" (?facet_Register@facet@locale@std@@CAXPAV123@@Z) 已经在 msvcprt.lib(locale0_implib.obj) 中定义
1>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(void)" (?_Getgloballocale@locale@std@@CAPAV_Locimp@12@XZ) 已经在 msvcprt.lib(MSVCP90.dll) 中定义
1>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Init(void)" (?_Init@locale@std@@CAPAV_Locimp@12@XZ) 已经在 msvcprt.lib(MSVCP90.dll) 中定义
1>libcpmtd.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z) 已经在 msvcprt.lib(MSVCP90.dll) 中定义
1>libcpmtd.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_dtor(class std::_Locinfo *)" (?_Locinfo_dtor@_Locinfo@std@@SAXPAV12@@Z) 已经在 msvcprt.lib(MSVCP90.dll) 中定义
1>libcpmtd.lib(ios.obj) : error LNK2005: "private: static void __cdecl std::ios_base::_Ios_base_dtor(class std::ios_base *)" (?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z) 已经在 msvcprt.lib(MSVCP90.dll) 中定义
1>libcpmtd.lib(ios.obj) : error LNK2005: "public: static void __cdecl std::ios_base::_Addstd(class std::ios_base *)" (?_Addstd@ios_base@std@@SAXPAV12@@Z) 已经在 msvcprt.lib(MSVCP90.dll) 中定义
1>libcpmtd.lib(xdebug.obj) : error LNK2005: "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义
1>libcpmtd.lib(xdebug.obj) : error LNK2005: "void * __cdecl operator new[](unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??_U@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义
1>libcpmtd.lib(xdebug.obj) : error LNK2005: "struct std::_DebugHeapTag_t const & __cdecl std::_DebugHeapTag_func(void)" (?_DebugHeapTag_func@std@@YAABU_DebugHeapTag_t@1@XZ) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义
1>libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) 已经在 msvcprt.lib(MSVCP90.dll) 中定义
1>libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) 已经在 msvcprt.lib(MSVCP90.dll) 中定义
1>LINK : warning LNK4098: 默认库“MSVCRT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========

#8


1. Debug 不是放代码和库的地方
2. 从你最的编译结果看,你的 .lib 用的编译器与你现在用的编译器不一致。你需要找一个使用你现在所用的编译器生成的 .lib ,或者自己重新编译一个。

#9


<>是引用系统库的,第三方库请用“”。
但怎么看也觉得是程序找不到文件地址,你确定你把这个库加进了你的项目了吗?
不太熟悉vs,具体怎么做不知道,但解决方法总归是将json的头文件加入header查询的path里。

#10


项目、属性、C/C++、附加包含目录:填写附加头文件所在目录 分号间隔多项
项目、属性、链接器、常规、附加库目录:填写附加依赖库所在目录 分号间隔多项
项目、属性、链接器、输入、附加依赖项:填写附加依赖库的名字.lib 空格或分号间隔多项

#11



fefe82:
            目 录已做调整,没有放在Debug下了,如下图示

无法打开包括文件:“json.h”: No such file or directory

.h 及lib库文件都放在如下目了
无法打开包括文件:“json.h”: No such file or directory

json Lib项目的配置如下图示:  (多线程调试(/MTd)) 
无法打开包括文件:“json.h”: No such file or directory

赵4老师:
                   按你说的项目重新设置了,还是通不过。

还请各位前辈再指点指点,是什么原因,谢谢。  


我的使用项目如果用: 原先我用"多线程 DLL (/MD)",现在改用“多线程调试(/MTd)”,编译通不过(如下所示),  运行时库那应该用哪一种呢?

1>lx_MFC2.cpp
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxver_.h(81) : fatal error C1189: #error :  Please use the /MD switch for _AFXDLL builds
1>lx_MFC.cpp
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxver_.h(81) : fatal error C1189: #error :  Please use the /MD switch for _AFXDLL builds

#12


补充一下我这个使用项目里用到了MFC,用到了以下http类,所以想用这个第三方Lib对返回的Json字符串做一个解析。
CInternetSession
CHttpFile

我看这个json类库的调用案例项目运行时刻库使用的也是:多线程调试(/MTd),为何我的调用项目不行,是与MFC有冲突?

#13


看到你的库是 json_vc71_libmtd.lib

这个是给 vc71 (vs2003) 用的,编译选项 /mtd 。

但是你的编译器是 vs2008 (vc9) 。编译器(版本)不同,是用不了的。

#14


引用 13 楼 fefe82 的回复:
看到你的库是 json_vc71_libmtd.lib

这个是给 vc71 (vs2003) 用的,编译选项 /mtd 。

但是你的编译器是 vs2008 (vc9) 。编译器(版本)不同,是用不了的。


是的,我是用的vs2008,但这个Json开源项目,下载源码后,我再用VS2008重编译了的,重新生的新Lib, 也不能用?
那如何解决呀?

#1


如果文件所在上当不是当前目录,需要将文件所在目录添加到项目属性中

另外:

#include <json.h>

改成

#include "json.h"

#2


引用 1 楼 paschen 的回复:
如果文件所在上当不是当前目录,需要将文件所在目录添加到项目属性中

另外:

#include <json.h>

改成

#include "json.h"


我的目录结构如下: 
F:\C++\excise\myExcise    (.cpp所在目录)
F:\C++\excise\myExcise\include     (json.h等h文件所在目录)
F:\C++\excise\myExcise\Debug\json    (json_vc71_libmtd.lib 文件所在目录)

改成 include "json.h" 还是不行,请指教,谢谢。
 java引用个jar包也没这么复杂。

#3


引用 2 楼 andylauxing 的回复:
Quote: 引用 1 楼 paschen 的回复:

如果文件所在上当不是当前目录,需要将文件所在目录添加到项目属性中

另外:

#include <json.h>

改成

#include "json.h"


我的目录结构如下: 
F:\C++\excise\myExcise    (.cpp所在目录)
F:\C++\excise\myExcise\include     (json.h等h文件所在目录)
F:\C++\excise\myExcise\Debug\json    (json_vc71_libmtd.lib 文件所在目录)

改成 include "json.h" 还是不行,请指教,谢谢。
 java引用个jar包也没这么复杂。


#include "F:\\C++\\excise\\myExcise\\Debug\\json.h"

#4



谢谢,兄台,.h可以了, 但又提示找不到.lib文件,错误提示如下:
fatal error LNK1104: 无法打开文件“json_vc71_libmtd.lib”

我的引用代码如下,难道这里也要加入路径??
#pragma comment(lib, "json_vc71_libmtd.lib")

#5


项目 -> 属性 - > 配置属性 -> C/C++ -> 常规附加包含目录
添加: ./ 


#6


右键项目--属性

.h文件这样做:
C/C++里的附加包含目录:F:\C++\excise\myExcise\Debug\

.lib这样做:
链接器--输入--附加依赖项添加上:json_vc71_libmtd.lib
链接器--常规--附加库目录添加上:F:\C++\excise\myExcise\Debug\json

#7


还是不行,错误如下:
1>------ 已启动生成: 项目: myExcise, 配置: Debug Win32 ------
1>正在编译..
1>正在链接...
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) 已经在 json_vc71_libmtd.lib(json_value.obj) 中定义

1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Lock(void)" (?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) 已经在 json_vc71_libmtd.lib(json_reader.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Unlock(void)" (?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) 已经在 json_vc71_libmtd.lib(json_reader.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) 已经在 json_vc71_libmtd.lib(json_value.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@ABV01@@Z) 已经在 json_vc71_libmtd.lib(json_value.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@ABV10@PBD@Z) 已经在 json_vc71_libmtd.lib(json_reader.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) 已经在 json_vc71_libmtd.lib(json_value.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::length(void)const " (?length@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) 已经在 json_vc71_libmtd.lib(json_value.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: bool __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::empty(void)const " (?empty@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE_NXZ) 已经在 json_vc71_libmtd.lib(json_reader.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator+=(char)" (??Y?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@D@Z) 已经在 json_vc71_libmtd.lib(json_reader.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: char const & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator[](unsigned int)const " (??A?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEABDI@Z) 已经在 json_vc71_libmtd.lib(json_writer.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::size(void)const " (?size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) 已经在 json_vc71_libmtd.lib(json_value.obj) 中定义
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::locale::facet * __thiscall std::locale::facet::_Decref(void)" (?_Decref@facet@locale@std@@QAEPAV123@XZ) 已经在 json_vc71_libmtd.lib(json_reader.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _printf 已经在 LIBCMTD.lib(printf.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _fclose 已经在 LIBCMTD.lib(fclose.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __mktime64 已经在 LIBCMTD.lib(mktime64.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _abort 已经在 LIBCMTD.lib(abort.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _malloc 已经在 LIBCMTD.lib(dbgmalloc.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _memcpy_s 已经在 LIBCMTD.lib(memcpy_s.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _isalpha 已经在 LIBCMTD.lib(_ctype.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _isdigit 已经在 LIBCMTD.lib(_ctype.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _isspace 已经在 LIBCMTD.lib(_ctype.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _ispunct 已经在 LIBCMTD.lib(_ctype.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _free 已经在 LIBCMTD.lib(dbgfree.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _calloc 已经在 LIBCMTD.lib(dbgcalloc.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __recalloc 已经在 LIBCMTD.lib(dbgheap.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _exit 已经在 LIBCMTD.lib(crt0dat.obj) 中定义
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strcpy_s 已经在 LIBCMTD.lib(strcpy_s.obj) 中定义
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) 已经在 LIBCMTD.lib(typinfo.obj) 中定义
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) 已经在 LIBCMTD.lib(typinfo.obj) 中定义
1>msvcrtd.lib(MSVCR90D.dll) : error LNK2005: __CrtDbgReportW 已经在 LIBCMTD.lib(dbgrptw.obj) 中定义
1>libcpmtd.lib(locale0.obj) : error LNK2005: "void __cdecl _AtModuleExit(void (__cdecl*)(void))" (?_AtModuleExit@@YAXP6AXXZ@Z) 已经在 msvcprt.lib(locale0_implib.obj) 中定义
1>libcpmtd.lib(locale0.obj) : error LNK2005: __Fac_tidy 已经在 msvcprt.lib(locale0_implib.obj) 中定义
1>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static void __cdecl std::locale::facet::facet_Register(class std::locale::facet *)" (?facet_Register@facet@locale@std@@CAXPAV123@@Z) 已经在 msvcprt.lib(locale0_implib.obj) 中定义
1>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(void)" (?_Getgloballocale@locale@std@@CAPAV_Locimp@12@XZ) 已经在 msvcprt.lib(MSVCP90.dll) 中定义
1>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Init(void)" (?_Init@locale@std@@CAPAV_Locimp@12@XZ) 已经在 msvcprt.lib(MSVCP90.dll) 中定义
1>libcpmtd.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z) 已经在 msvcprt.lib(MSVCP90.dll) 中定义
1>libcpmtd.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_dtor(class std::_Locinfo *)" (?_Locinfo_dtor@_Locinfo@std@@SAXPAV12@@Z) 已经在 msvcprt.lib(MSVCP90.dll) 中定义
1>libcpmtd.lib(ios.obj) : error LNK2005: "private: static void __cdecl std::ios_base::_Ios_base_dtor(class std::ios_base *)" (?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z) 已经在 msvcprt.lib(MSVCP90.dll) 中定义
1>libcpmtd.lib(ios.obj) : error LNK2005: "public: static void __cdecl std::ios_base::_Addstd(class std::ios_base *)" (?_Addstd@ios_base@std@@SAXPAV12@@Z) 已经在 msvcprt.lib(MSVCP90.dll) 中定义
1>libcpmtd.lib(xdebug.obj) : error LNK2005: "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义
1>libcpmtd.lib(xdebug.obj) : error LNK2005: "void * __cdecl operator new[](unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??_U@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义
1>libcpmtd.lib(xdebug.obj) : error LNK2005: "struct std::_DebugHeapTag_t const & __cdecl std::_DebugHeapTag_func(void)" (?_DebugHeapTag_func@std@@YAABU_DebugHeapTag_t@1@XZ) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义
1>libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) 已经在 msvcprt.lib(MSVCP90.dll) 中定义
1>libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) 已经在 msvcprt.lib(MSVCP90.dll) 中定义
1>LINK : warning LNK4098: 默认库“MSVCRT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========

#8


1. Debug 不是放代码和库的地方
2. 从你最的编译结果看,你的 .lib 用的编译器与你现在用的编译器不一致。你需要找一个使用你现在所用的编译器生成的 .lib ,或者自己重新编译一个。

#9


<>是引用系统库的,第三方库请用“”。
但怎么看也觉得是程序找不到文件地址,你确定你把这个库加进了你的项目了吗?
不太熟悉vs,具体怎么做不知道,但解决方法总归是将json的头文件加入header查询的path里。

#10


项目、属性、C/C++、附加包含目录:填写附加头文件所在目录 分号间隔多项
项目、属性、链接器、常规、附加库目录:填写附加依赖库所在目录 分号间隔多项
项目、属性、链接器、输入、附加依赖项:填写附加依赖库的名字.lib 空格或分号间隔多项

#11



fefe82:
            目 录已做调整,没有放在Debug下了,如下图示

无法打开包括文件:“json.h”: No such file or directory

.h 及lib库文件都放在如下目了
无法打开包括文件:“json.h”: No such file or directory

json Lib项目的配置如下图示:  (多线程调试(/MTd)) 
无法打开包括文件:“json.h”: No such file or directory

赵4老师:
                   按你说的项目重新设置了,还是通不过。

还请各位前辈再指点指点,是什么原因,谢谢。  


我的使用项目如果用: 原先我用"多线程 DLL (/MD)",现在改用“多线程调试(/MTd)”,编译通不过(如下所示),  运行时库那应该用哪一种呢?

1>lx_MFC2.cpp
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxver_.h(81) : fatal error C1189: #error :  Please use the /MD switch for _AFXDLL builds
1>lx_MFC.cpp
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxver_.h(81) : fatal error C1189: #error :  Please use the /MD switch for _AFXDLL builds

#12


补充一下我这个使用项目里用到了MFC,用到了以下http类,所以想用这个第三方Lib对返回的Json字符串做一个解析。
CInternetSession
CHttpFile

我看这个json类库的调用案例项目运行时刻库使用的也是:多线程调试(/MTd),为何我的调用项目不行,是与MFC有冲突?

#13


看到你的库是 json_vc71_libmtd.lib

这个是给 vc71 (vs2003) 用的,编译选项 /mtd 。

但是你的编译器是 vs2008 (vc9) 。编译器(版本)不同,是用不了的。

#14


引用 13 楼 fefe82 的回复:
看到你的库是 json_vc71_libmtd.lib

这个是给 vc71 (vs2003) 用的,编译选项 /mtd 。

但是你的编译器是 vs2008 (vc9) 。编译器(版本)不同,是用不了的。


是的,我是用的vs2008,但这个Json开源项目,下载源码后,我再用VS2008重编译了的,重新生的新Lib, 也不能用?
那如何解决呀?