0

I wanted to run a simple code in c++. Just to try work with JSON file. I'm working in Microsoft VS 2013. I downloaded 'include' folder with header files in, and put it in my current MVS project's folder, it's ok. When I start build my program it says:

  1. error LNK2019: unresolved external symbol "public: __thiscall Json::Value::Value(enum Json::ValueType)" (??0Value@Json@@QAE@W4ValueType@1@@Z) referenced in function _main C:\Users\Julia\Dropbox\julia\pro\cpp\30\testJson\testJson\Source.obj testJson
  2. error LNK2019: unresolved external symbol "public: __thiscall Json::Value::~Value(void)" (??1Value@Json@@QAE@XZ) referenced in function _main C:\Users\Julia\Dropbox\julia\pro\cpp\30\testJson\testJson\Source.obj testJson
  3. error LNK2019: unresolved external symbol "class std::basic_istream > & __cdecl Json::operator>>(class std::basic_istream > &,class Json::Value &)" (??5Json@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@std@@AAV12@AAVValue@0@@Z) referenced in function _main C:\Users\Julia\Dropbox\julia\pro\cpp\30\testJson\testJson\Source.obj testJson
  4. error LNK2019: unresolved external symbol "class std::basic_ostream > & __cdecl Json::operator<<(class std::basic_ostream > &,class Json::Value const &)" (??6Json@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV12@ABVValue@0@@Z) referenced in function _main C:\Users\Julia\Dropbox\julia\pro\cpp\30\testJson\testJson\Source.obj testJson
  5. error LNK1120: 4 unresolved externals C:\Users\Julia\Dropbox\julia\pro\cpp\30\testJson\Debug\testJson.exe testJson
#include "json/json.h"
#include <iostream>
#include <fstream>


int main()
{
    Json::Value root;
    std::ifstream file("file.json");
    file >> root;
    std::cout << root;
}
πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
JuliaKo
  • 731
  • 1
  • 11
  • 19
  • 4
    _'How I can get through this errors '_ Best by 1st reading all the answers that can be found here: [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – πάντα ῥεῖ Jun 24 '14 at 18:21
  • 2
    I don't understand the downvote. We should expect to have to teach new users at this site. The OP's question was given with a clear and complete sample (which will go wrong if you don't link the -ljson accordingly). The question is a duplicate nothing more nothing less, these usually don't need downvotes in 1st place. – πάντα ῥεῖ Jun 24 '14 at 18:33
  • what the '-ljson' is? – JuliaKo Jun 24 '14 at 18:38
  • @julia-kozh Obviously you missed to provide the correct json library to the linking stage of your program. I don't know exactly, please refer to the libjson documentation, which is the actual library name (but I'd suspect something like `-ljson` + `-L should be sufficient). – πάντα ῥεῖ Jun 24 '14 at 18:39
  • @julia-kozh Don't hesitate to ask another question (or [edit](http://stackoverflow.com/posts/24393633/edit) and ask for reopening) if any of the above hints don't fit to finally solve your problem. Be specific then about your finally linking command line (whatever toolchain/IDE you are actually using), the example options I gave are applicable for a number of different c/c++ compiler tool chains e.g. [tag:gcc] or [tag:clang], other compilers might need different flags). – πάντα ῥεῖ Jun 24 '14 at 18:55
  • I found this example https://github.com/amir-sabbaghi/libjson-- I copied and pasted all files, but I have the same errors. Error 1 error LNK2019: unresolved external symbol "public: __thiscall Json::Json(void)" (??0Json@@QAE@XZ) referenced in function "public: class Json & __thiscall Json::operator[](class std::basic_string,class std::allocator > const &)" (??AJson@@QAEAAV0@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) ... – JuliaKo Jun 24 '14 at 19:14
  • @julia-kozh OK, as stated in your question, downloading the include folder isn't enough. You'll either need to have the appropriate corresponding `.lib` files, or source (`.cpp`) files, where you can build the lib from. As far I can see there's only a single `json.cpp` file provided, you can also add this one to your project files to be linked directly (without linking a library). – πάντα ῥεῖ Jun 24 '14 at 19:19
  • 1
    Thanks, problem solved as you said – JuliaKo Jun 24 '14 at 19:35

0 Answers0