-2

I m new on json, I trying to read my json file from this tutorial site https://en.wikibooks.org/wiki/JsonCpp

however I get some linker error

1>------ Build started: Project: TwilightAdventure, Configuration: Debug Win32 ------ 1> Creating library C:\Users\MinTeckNG\Desktop\TwilightAdventure\Debug\TwilightAdventure.lib and object C:\Users\MinTeckNG\Desktop\TwilightAdventure\Debug\TwilightAdventure.exp 1>LoadingMap.obj : error LNK2019: unresolved external symbol "public: __thiscall Json::Reader::Reader(void)" (??0Reader@Json@@QAE@XZ) referenced in function "public: void __thiscall LoadingMap::ReadJsonFileTest(void)" (?ReadJsonFileTest@LoadingMap@@QAEXXZ) 1>C:\Users\MinTeckNG\Desktop\TwilightAdventure\Debug\TwilightAdventure.exe : fatal error LNK1120: 1 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

error picture lnk2019 unresolved external symbol

my json file going to read

{
"actors": [
    {
        "name": "Ground",
        "pos": {
            "x": 2592.0,
            "y": 96.0
        }
    },
    {
        "name": "Grass",
        "pos": {
            "x": 2656.0,
            "y": 96.0
        }
    }
 }

my code

#include "LoadingMap.h"
#include <fstream>

LoadingMap::LoadingMap(void)
{
}

LoadingMap::~LoadingMap(void)
{
 }

/*const char *LoadingMap::GetFileName(int stage, int difficulties)
 {
char a = '0';
const char *ptr = &a;
return ptr;
 }*/
 /*void LoadingMap::ReadJsonFile(const char *filename)
 {

    }*/

     void LoadingMap::ReadJsonFileTest()
      {
std::ifstream ifs("1-1-0.json");
Json::Reader reader;
//Json::Value obj;
//reader.parse(ifs, obj); 
//std::cout << "Object type: " << obj["name"].asString() << std::endl;

//const Json::Value& pos = obj["pos"]; 

//std::cout << " x: " << pos[0]["x"].asUInt();
//std::cout << " y: " << pos[1]["y"].asUInt();

    }

my header file

#pragma once
#include <iostream>
#include <fstream>
#include <json/json.h>

class LoadingMap
{
public:
LoadingMap(void);
~LoadingMap(void);

//const char *GetFileName(int stage, int difficulties);
//void ReadJsonFile(const char *filename);
void ReadJsonFileTest();
 private:

 };

well the code is mainly nothing , nothing implement yet, all I try to follow the tutorial and modify .

clarence ng
  • 19
  • 1
  • 7
  • 3
    Please post the linker error, remove the unneeded comments and poste the whole LoadingMap Code – Superlokkus Feb 05 '18 at 13:58
  • Copy the text of the error message from the Output Tab. Its in a format that should make it easy to copy and paste into your question. – drescherjm Feb 05 '18 at 14:02
  • the error picture link, show my visual studio error – clarence ng Feb 05 '18 at 14:11
  • At stackoverflow pictures of text are not welcome because what happens to the picture 2 years from now? The idea of a question is not to help 1 person but people years from now. Also a picture of text is not easily searched when the actual text is easy to see and search. – drescherjm Feb 05 '18 at 14:15
  • but I can't copy the link error description – clarence ng Feb 05 '18 at 14:25
  • 1
    It's very simple: You haven't linked to your dependency Json::Reader. – Superlokkus Feb 05 '18 at 14:31
  • I did #include at my .h file – clarence ng Feb 05 '18 at 14:32
  • 1
    Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Tadeusz Kopec for Ukraine Feb 05 '18 at 15:08
  • Including a header file is usually not linking a library. I say usually because MSVC does have a way to force linker settings using a #pragma. – drescherjm Feb 05 '18 at 18:00

1 Answers1

0

changed to rapidjson instead jsoncpp. everything seem ok for now.

clarence ng
  • 19
  • 1
  • 7