Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'nlohmann/json.hpp' file not found #2188

Closed
Honorable22 opened this issue Jun 12, 2020 · 23 comments
Closed

'nlohmann/json.hpp' file not found #2188

Honorable22 opened this issue Jun 12, 2020 · 23 comments
Labels
solution: invalid the issue is not related to the library state: needs more info the author of the issue needs to provide more details

Comments

@Honorable22
Copy link

For some reason I am getting this error message on basic setup when running this library on VS Code:

UIDeveloperTest.cpp:26:10: fatal error: 'nlohmann/json.hpp' file not found
#include "nlohmann/json.hpp"
^~~~~~~~~~~~~~~~~~~
1 error generated.

I can not seem to find the solution to this error.

@nlohmann nlohmann added the state: needs more info the author of the issue needs to provide more details label Jun 13, 2020
@nlohmann
Copy link
Owner

In order to asses your issue, we need the following information:

  • What is the issue you have?

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?

  • What is the expected behavior?

  • And what is the actual behavior instead?

  • Which compiler and operating system are you using? Is it a supported compiler?

  • Did you use a released version of the library or the version from the develop branch?

  • If you experience a compilation error: can you compile and run the unit tests?

@Honorable22
Copy link
Author

Honorable22 commented Jun 13, 2020

When trying to include the library with the following line:

#include <iostream>
#include <fstream>
#include <cmath>

#include "nlohmann/json.hpp"

using json = nlohmann::json;

using namespace std;

int main() {
  cout << "Hello World!";
  return 0;
}

I get this error after I compile it:
fatal error: 'nlohmann/json.hpp' file not found

I am running Visual Studio Code on a Mac I believe its being compiled using clang

@nlohmann
Copy link
Owner

Where did you put the json.hpp file?

@Honorable22
Copy link
Author

Inside of a folder labeled nlohmann and then that is inside of a folder labeled include.

@nlohmann
Copy link
Owner

I am not familiar with Visual Studio Code. Maybe change the include to #include <nlohmann/json.hpp> and try to set the include path to your project path.

@Honorable22
Copy link
Author

Yes I tried to change include to <nlohmann/json.hpp>, it didn't make a difference.

@nlohmann
Copy link
Owner

What’s the include path? Which build system are you using?

@Honorable22
Copy link
Author

Honorable22 commented Jun 14, 2020

"includePath": [
"${workspaceFolder}/**"
],

using clang++ as the build system

@nlohmann
Copy link
Owner

I'm sorry, I have no idea how to fix this error as it is not related to this library. Please seek help in a forum for VS Code.

@nlohmann nlohmann added the solution: invalid the issue is not related to the library label Jun 14, 2020
@shivam-51
Copy link

@Honorable22 Did you get any solution?

@Honorable22
Copy link
Author

Honorable22 commented Sep 29, 2020 via email

@shivam-51
Copy link

Never mind, My code compiles now :)

@Honorable22
Copy link
Author

Honorable22 commented Sep 29, 2020 via email

@shivam-51
Copy link

What was your solution?

First I had to install the nlohmann_json package from apt sudo apt install nlohmann-json-dev
then simply g++ file.cpp

@Honorable22
Copy link
Author

Honorable22 commented Sep 29, 2020 via email

@kevinmukuna
Copy link

if you experience the same issue. you can solve it by adding (nlohmann-json) the path to c_cpp_properties.json like this

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**",
                "/opt/homebrew/Cellar/nlohmann-json/3.10.5/include/"
            ],
           ...
          ...

c_cpp_properties.json can be found in your current working dir under .vscode dir

@maxpain
Copy link

maxpain commented Jul 2, 2022

@kevinmukuna didn't help :(

@anu-n87
Copy link

anu-n87 commented Dec 22, 2022

I tried installing nlohmann json and some files found missing in /usr/include/nlohmann. I used sudo apt-get install nlohmann-json3-dev for installation and it was success. However some files are missing which I use in my code and hence the code is having compilation issues. I tried copying those files from other system. But it did not work :( My system details:
Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal
Architecture is arm64.
Can anyone please help to get it resolved?

@nlohmann : Could you please help on this?

@nlohmann
Copy link
Owner

nlohmann commented Jan 4, 2023

I am not maintaining this package. Please contact the maintainer.

@anu-n87
Copy link

anu-n87 commented Jan 4, 2023

I am not maintaining this package. Please contact the maintainer.

@nlohmann Thanks for the reply. Can I please know the details of the maintainer?

@nlohmann
Copy link
Owner

nlohmann commented Jan 4, 2023

I do not know. You should be able to look this up in your distro.

@vidyulshah
Copy link

When I do sudo apt install nlohmann-json-dev
It give me this:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package nlohmann-json-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
Any other solution or stable branch available?

@aseem-heg
Copy link

sudo apt install libstdc++-12-dev this also did not resolve this error.
still getting error

.plugin_symlinks/flutter_secure_storage_linux/linux/include/json.hpp:18:8: error: macro name missing
/home/aseem/code/pangea_flutter/linux/flutter/ephemeral/.plugin_symlinks/flutter_secure_storage_linux/linux/include/Secret.hpp:12:17: error: implicit instantiation of undefined template 'std::basic_string<char>'
/home/aseem/code/pangea_flutter/linux/flutter/ephemeral/.plugin_symlinks/flutter_secure_storage_linux/linux/include/Secret.hpp:57:25: error: use of undeclared identifier 'nlohmann'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: invalid the issue is not related to the library state: needs more info the author of the issue needs to provide more details
Projects
None yet
Development

No branches or pull requests

8 participants