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

EOS compilation produces "fatal error: 'nlohmann/json.hpp' file not found" #1432

Closed
ekkis opened this issue Jan 14, 2019 · 4 comments
Closed
Labels
solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@ekkis
Copy link

ekkis commented Jan 14, 2019

I'll start by admitting this may belong in the EOS support but just in case someone here knows about this I'm posting here

  • What is the issue you have?

cannot seem to include the .hpp file in my EOS project

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

$ brew tap nlohmann/json
$ brew install nlohmann_json
$ brew test nlohmann_json
$ cat "#include <nlohmann/json.hpp>" > t.cpp
$ eosio-cpp -o t.wasm t.cpp --abigen

  • What is the expected behavior?

successful compilation

  • And what is the actual behavior instead?

t.cpp:1:10: fatal error: 'nlohmann/json.hpp' file not found
#include <nlohmann/json.hpp>
^~~~~~~~~~~~~~~~~~~
1 error generated.

using the EOS compiler

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

the released version

I presume these are run with brew test ... -- they ran successfully (no errors)

@ekkis
Copy link
Author

ekkis commented Jan 14, 2019

@nlohmann it would be great if we could have support for this library within EOS but it's a rather restrictive environment. I cross posted this issue and got a discouraging reply but perhaps something that would encourage you to look into it, as a challenge, perhaps?

EOSIO/eosio.contracts#167

@nlohmann
Copy link
Owner

This seems to be a problem with the include directories which is more related to the invocation of the compiler rather than the compiler itself. The brew command outputs (brew info nlohmann_json):

If built with CMake support, you can use find_package to use the library.

Without it, please set your include path accordingly:
CPPFLAGS: -I/usr/local/opt/nlohmann_json/include

I do not know the compiler that you are using, but you should try

eosio-cpp -I/usr/local/opt/nlohmann_json/include -o t.wasm t.cpp --abigen

@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Jan 15, 2019
@nlohmann
Copy link
Owner

@ekkis Does this solve your issue?

@ekkis
Copy link
Author

ekkis commented Jan 28, 2019

what I did was just to download, the .hpp, put it in the local directory and include it like #include "json.hpp"; -- however it was a futile effort because EOS is a very restrictive environment and doing Json parsing in it would make the smart contracts substantially larger so I dumped the whole concept

thanks for the reply and attempt to help all the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants