Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Undefined symbol compilation error on Mac OSX when using std::unordered_map #685

@calebmcelroy

Description

@calebmcelroy

I can't seem to compile when using an unordered_map. If I instead simply change to std::map, it compiles & works just fine. Below is the info needed to hopefully reproduce.

Let me know if I'm doing something wrong.

Command Line:

eosio-cpp -o testmap.wasm -abigen testmap.cpp

Error Message:
/usr/local/Cellar/eosio.cdt/1.6.2/opt/eosio.cdt/bin/wasm-ld: error: /var/folders/w1/wyt3d2ws7f16gkxw3r9_x_3h0000gn/T//testmap.cpp.o: undefined symbol: std::__1::__next_prime(unsigned int)

Source Code:

#include <eosio/eosio.hpp>
#include <eosio/print.hpp>
#include <string>
#include <unordered_map>

using namespace eosio;

class [[eosio::contract("testmap")]] testmap : public contract {
  public:
      using contract::contract;

      /*
         unordered map test
      */
      [[eosio::action]]
      void hi(std::string username) {
        // only allow alphanumeric and dots (a-z A-Z 0-9 .)
        std::unordered_map<char, char> allowedCharactersHash({
            {'a', 'a'}, {'b', 'b'}, {'c', 'c'}, {'d', 'd'}, {'e', 'e'}, {'f', 'f'}, {'g', 'g'}, {'h', 'h'},
            {'i', 'i'}, {'j', 'j'}, {'k', 'k'}, {'l', 'l'}, {'m', 'm'}, {'n', 'n'}, {'o', 'o'}, {'p', 'p'},
            {'q', 'q'}, {'r', 'r'}, {'s', 's'}, {'t', 't'}, {'u', 'u'}, {'v', 'v'}, {'w', 'w'}, {'x', 'x'},
            {'y', 'y'}, {'z', 'z'}, {'A', 'A'}, {'B', 'B'}, {'C', 'C'}, {'D', 'D'}, {'E', 'E'}, {'F', 'F'},
            {'G', 'G'}, {'H', 'H'}, {'I', 'I'}, {'J', 'J'}, {'K', 'K'}, {'L', 'L'}, {'M', 'M'}, {'N', 'N'},
            {'O', 'O'}, {'P', 'P'}, {'Q', 'Q'}, {'R', 'R'}, {'S', 'S'}, {'T', 'T'}, {'U', 'U'}, {'V', 'V'},
            {'W', 'W'}, {'X', 'X'}, {'Y', 'Y'}, {'Z', 'Z'}, {'1', '1'}, {'2', '2'}, {'3', '3'}, {'4', '4'},
            {'5', '5'}, {'6', '6'}, {'7', '7'}, {'8', '8'}, {'9', '9'}, {'0', '0'}, {'.', '.'}
        });

        for (char &c: username) {
            check(allowedCharactersHash.count(c) == 0, "Username is limited to containing alphanumeric(A-Z a-z 0-9) and dots(.).");
        }

        print("Hello, ", username, "\n");
      }
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions