Running an example on VisualStudioCode

Hi, I am new using OPENFHE and I am having problems when running examples in OpenFHE. I am trying to run: /home/usuario/prueba/openfhe-development/src/binfhe/examples/pke/boolean-pke.cpp but I find the following error: “binfhecontext.h: No such file or directory”, which actually is in: /usr/local/include/openfhe/binfhe/binfhecontext.h.

I tried adding the paths in settings.json: {
“files.watcherExclude”: {
/build/”: true
},
“C_Cpp.default.includePath”: [
“/usr/local/include/openfhe/core”,
“/usr/local/include/openfhe/pke”,
“/usr/local/include/openfhe/cereal”,
“/usr/local/include/openfhe/binfhe”,
“${workspaceFolder}/**”
]
}

and also in /home/usuario/prueba/openfhe-development/.vscode/c_cpp_properties.json: {
“configurations”: [
{
“name”: “Linux”,
“includePath”: [
{workspaceFolder}/**", "/usr/local/include/openfhe", "/usr/local/include/openfhe/core", "/usr/local/include/openfhe/pke", "/usr/local/include/openfhe/cereal", "/usr/local/include/openfhe/binfhe", "{workspaceFolder}/**”
],
“defines”: ,
“compilerPath”: “/usr/bin/gcc”,
“cStandard”: “c17”,
“cppStandard”: “gnu++14”,
“intelliSenseMode”: “linux-gcc-x64”
}
],
“version”: 4
}

But I still got the same error. How can I fix it?

I am not sure what caused this problem. I have been using VS Code to develop OpenFHE code for more than 2 years now and I never faced this issue.

Let me walk you through my setup which might resolve your issue.

  1. Clone the OpenFHE repository:

    cd /user/home/
    git clone https://github.com/openfheorg/openfhe-development.git

  2. Open the project in VS Code:

    cd openfhe-development
    code .

  3. Verify that your root directory is “OpenFHE” in VS Code, as shown in the screenshot below
    image
  4. Open a terminal in VS Code:
    • Go to View in the menu bar
    • Select Terminal
  5. In the VS Code terminal, build the project as follows:

    mkdir build
    cd build
    cmake ..
    make

  6. Create a .vscode folder in your workspace:
    • In the VS Code file explorer, create a new folder right inside the openfhe-development folder
    • Select New Folder
    • Name it .vscode
  7. Create a tasks.json file:
    • Right-click on the .vscode folder
    • Select New File
    • Name it tasks.json
  8. Add the following JSON code to tasks.json:
    {
      "version": "2.0.0",
      "tasks": [
        {
          "label": "Build and Run Example",
          "type": "shell",
          "command": "cd ${workspaceFolder}/build/bin/examples/binfhe && ./boolean-ap",
          "group": {
            "kind": "build",
            "isDefault": true
          },
          "problemMatcher": []
        }
      ]
    }
    
  9. To run the program:
    • Press Ctrl+Shift+P to open the command palette
    • Type Run Task and select it
    • Choose Build and Run Example from the list of tasks

Hope this helps.

1 Like