4

I need to include jsoncpp in my visual studio code.

Is there any way to include .lib file in visual studio code?

this is my c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/*",
                "${workspaceFolder}/C++Script/Dependencies/include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.16299.0",
            "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/bin/Hostx64/x64/cl.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "msvc-x64"
        }
    ],
    "version": 4
}

enter image description here

I included json.h( although my compiler says it can't find the header file ) and I would like to include .lib file as well.

Can you tell me how to do that? I do know how to do this in visual studio. ( with liker )

Antonio SEO
  • 457
  • 1
  • 9
  • 23

2 Answers2

0

c_cpp_properties.json is for Intellisense, you need to use tasks.json. Example:

{
    "version": "2.0.0",
    "tasks": [
      {
        "type": "shell",
        "label": "cl.exe build active file",
        "command": "cl.exe",
        "args": [
          "/Zi",
          "/EHsc",
          "/Fe:",
          "${fileDirname}\\${fileBasenameNoExtension}.exe",
          "${file}",
          "/I",
          "C:\\vcpkg\\installed\\x86-windows\\include"
        ],
        ...
  }
Tadas Talaikis
  • 121
  • 1
  • 2
  • 6
0

As suggested here:

[...] Say A.exe depends B.dll. You need to include B's header in A.cpp (#include "B.h") then compile and link with B.lib: [...] cl A.cpp /EHsc /link B.lib "

therefore, with Visual Studio Code (v1.81), you have to edit your .vscode\tasks.json section "args" adding:

 "args": [
    ...
    "/link", 
    "B.lib"
  ]

please check that the path of your header file (ie: B.h) is also set properly in .vscode\tasks.json:

 "args": [
    ...
    "/I",
    "C:\\path\\to\\your\\include",
    ...
    "/link", 
    "C:\\path\\to\\your\\B.lib"
  ]
albezanc
  • 25
  • 7