0

Here is the code I am trying to compile in Visual Studio 2017.

#include "stdafx.h"
#define _WINSOCKAPI_
#include <httpserv.h>
#include "json.h"
#include "json-forwards.h"
#include <iostream>
#include <fstream>

HRESULT
__stdcall
RegisterModule(DWORD dwServerVersion, IHttpModuleRegistrationInfo * pModuleInfo, IHttpServer * pGlobalInfo)
{
    UNREFERENCED_PARAMETER(dwServerVersion);
    UNREFERENCED_PARAMETER(pGlobalInfo);

    bool alive = true;

    MyGlobalModule * pGlobalModule = new MyGlobalModule;

    if (NULL == pGlobalModule)
    {
        return HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
    }

    while (alive) {
        Json::Reader reader;
        Json::Value root;
        std::ifstream push_manifest("push_manifest.json", std::ifstream::binary);
        bool parsingSuccessful = reader.parse(push_manifest, root, false);

        if (!parsingSuccessful)
        {
            // report to the user the failure and their locations in the document.
            std::cout << reader.getFormatedErrorMessages()
                << "\n";
        }

        std::string encoding = root.get("encoding", "UTF-8").asString();
        std::cout << encoding << "\n";
        alive = false;
    }

    return pModuleInfo->SetGlobalNotifications(
        pGlobalModule, GL_PRE_BEGIN_REQUEST);
}

Getting the below Errors while compiling.Please suggest what is wrong since the errors don't explain anything.

Visual Studio Compilation error

sepp2k
  • 363,768
  • 54
  • 674
  • 675
  • Your question would be easier to read if the error messages were included directly, not just as an external link to an image. Thanks. – rwp Jun 10 '18 at 06:33
  • What does your question have to do with compiler construction? You're not linking whatever json lib you're using. – Retired Ninja Jun 10 '18 at 06:54
  • You should probably give som json library (.lib) to the linker, but we cannot tell either from the info in the question. – Bo Persson Jun 10 '18 at 08:42
  • My question is simple, the linker error that I get is too generic and doesn't clearly mention specific cause of error....how to identify what causing the issue ? – Sayak Bhattacharya Jun 10 '18 at 11:00
  • I'm not sure why you consider `unresolved token Json::Whatever` generic. It seems very specific to me. Certainly enough to narrow down what library you're missing. – Retired Ninja Jun 11 '18 at 02:17
  • The answer mentioned in `What is an undefined reference/unresolved external symbol error and how do I fix it?` is very generic. Here is the specific answer to my query. The issue happened since I was not linking the specific DLLs in the Visual Studio. So 2 things needs to be done. 1. Goto project properties -> C/C++ -> General and then provide "additional include directories". 2. Goto Linker -> Input -> add Additional Dependencies. These solves my issue. – Sayak Bhattacharya Jul 12 '18 at 16:34

0 Answers0