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

eosio.wasmsdk error #1284

Closed
cppfuns opened this issue Oct 9, 2018 · 9 comments
Closed

eosio.wasmsdk error #1284

cppfuns opened this issue Oct 9, 2018 · 9 comments

Comments

@cppfuns
Copy link

cppfuns commented Oct 9, 2018

I am trying to use the following C++ JSON library:

https://github.com/nlohmann/json

Below is the code I am trying to compile with eosio-cpp gda.cpp -o gda.wasm

#include <eosiolib/eosio.hpp>
#include <nlohmann/json.hpp>
#include <string>

using json = nlohmann::json;

class gda : public eosio::contract {
    public:
        explicit gda(action_name self) : contract(self) {}

        // @abi action
        void doit(const std::string action) {
            json j = {
                {"pi", 3.141},
                {"happy", true},
                {"name", "Niels"},
                {"nothing", nullptr},
                {"answer", {
                    {"everything", 42}
                }},
                {"list", {1, 0, 2}},
                {"object", {
                    {"currency", "USD"},
                    {"value", 42.99}
                }}
            };
            std::string d = j.dump();
        }
};

EOSIO_ABI( gda, (doit) )
Below is the output from trying to compile:

/usr/local/eosio.wasmsdk/bin/wasm-ld: error: locale.cpp.o: undefined symbol: strftime_l
/usr/local/eosio.wasmsdk/bin/wasm-ld: error: memory.cpp.o: undefined symbol: __cxa_pure_virtual
/usr/local/eosio.wasmsdk/bin/wasm-ld: error: system_error.cpp.o: undefined symbol:__cxa_pure_virtual

If the j.dump() line is commented out, the contract will compile.
A similar issue has been raised on stackoverflow.

https://stackoverflow.com/questions/52350514/linking-issue-with-eosio-ld

I was directed here from: EOSIO/eos#5832

@cppfuns
Copy link
Author

cppfuns commented Oct 9, 2018

The json library has been used incorrectly in the eos contract. I hope it will help here.

@theodelrieu
Copy link
Contributor

I've never used eosio, but the __cxa_* symbols looks like it's missing libc++abi in the linker command line.

I don't find strftime_l in my libc++, even though there's strftime.

@cppfuns
Copy link
Author

cppfuns commented Oct 9, 2018

At present, the eos blockchain urgently needs a json parsing library. At present, nlohmann/json is the most suitable, but there is this error, although I don't know where the problem is, but it is very difficult.
Many friends have encountered the same problem these few days.

@nlohmann
Copy link
Owner

nlohmann commented Oct 9, 2018

Is it possible to get the eosio-cpp compiler somewhere and run it under, say, macOS?

@cppfuns
Copy link
Author

cppfuns commented Oct 9, 2018

Is it possible to get the eosio-cpp compiler somewhere and run it under, say, macOS?

https://github.com/EOSIO/eosio.cdt

Very easy to compile and run, I will always stare at this post, I am still good at eos, if you have problems, you can reply at any time, I will reply

@cppfuns
Copy link
Author

cppfuns commented Oct 9, 2018

$ git clone --recursive https://github.com/eosio/eosio.cdt
$ cd eosio.cdt
$ ./build.sh EOS
$ sudo ./install.sh

Then create a new gda.cpp file

#include <eosiolib/eosio.hpp>
#include <nlohmann/json.hpp>
#include <string>

using json = nlohmann::json;

class gda : public eosio::contract {
    public:
        explicit gda(action_name self) : contract(self) {}

        // @abi action
        void doit(const std::string action) {
            json j = {
                {"pi", 3.141},
                {"happy", true},
                {"name", "Niels"},
                {"nothing", nullptr},
                {"answer", {
                    {"everything", 42}
                }},
                {"list", {1, 0, 2}},
                {"object", {
                    {"currency", "USD"},
                    {"value", 42.99}
                }}
            };
            std::string d = j.dump();
        }
};

Final execution
eosio-cpp gda.cpp -o gda.wasm

@cppfuns
Copy link
Author

cppfuns commented Oct 9, 2018

@nlohmann
Are you following up on this issue? Any progress?
I am more anxious to confirm the plan here.

@nlohmann
Copy link
Owner

nlohmann commented Oct 9, 2018

The errors seem to be unrelated to the library as they do not mention a library function. It seems that the compiler/STL is missing some standard features.

@nlohmann
Copy link
Owner

nlohmann commented Oct 9, 2018

I am closing the issue. Feel free to reopen if you have an error more related to the library.

@nlohmann nlohmann closed this as completed Oct 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants