2016-11-08 65 views
0

我能夠使用JsonCPP(https://github.com/open-source-parsers/jsoncpp)創建測試WinApp來解析json文件。 然而,當我實現了與C/C++的MFC C++項目相似 - >預編譯頭選項設置爲使用預編譯頭(/羽)在VS2008時,出現此錯誤:如何使JsonCPP在MFC C++項目中工作

c:\users\user1\documents\visual studio 2008\projects\jsonutility\jsonutility\jsonTest.cpp(371) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?

如果我加上「#包括‘stdafx.h中’」我JsonTest.cpp,我會得到這個錯誤:

JsonTest.obj : error LNK2019: unresolved external symbol "public: class Json::Value & __thiscall Json::Value::operator[](char const *)" ([email protected]@@[email protected]@Z) referenced in function "public: void __thiscall JsonTest::readConfig(char const *)" ([email protected]@@[email protected])

我已經嘗試了現在近2天,但沒有成功。 我已經加入我的附加包含目錄如下:

C:\用戶\用戶1 \文檔\ Visual Studio 2008的\項目\ JsonUtility \ ReadingJson \ DIST

C:\ Program Files文件(x86)的\微軟的Visual Studio 9.0 \ VC \包括

C:\ USR \ jsoncpp主\包括

+1

這是一個鏈接器錯誤。如果你已經構建了jsoncpp,你應該有一個.lib文件。將.lib文件添加到項目的配置屬性>鏈接器>輸入>其他依賴項。 – acraig5075

回答

1

我好像你不包括JSONCPPs * .cpp文件到您的項目(他們必須編譯和鏈接)。如果庫被編譯爲靜態庫,則必須告訴鏈接器要鏈接的內容。

+0

我將我的項目配置爲「在靜態庫中使用MFC」。我放棄了包含json.h,json-forwards.h和jsoncpp.cpp的項目中的dist文件夾,但它似乎不夠。所以我按照你的建議,將json_vc71_libmtd.lib添加到我的項目中,並將.lib名稱添加到Linker-> Input-> Additional Dependencies並刪除3個json文件,它解決了這個問題。 – Key

相關問題