billyquith / ponder

C++ reflection library with Lua binding, and JSON and XML serialisation.
http://billyquith.github.io/ponder/
Other
648 stars 95 forks source link

Use runtime error #124

Open jackfong123 opened 3 years ago

jackfong123 commented 3 years ago
class Person
{
public:
     // constructor
    Person(const std::string& name)
        : m_name(name)
    {}

    // accessors for private members
    std::string name() const { return m_name; }
    void setName(const std::string& name) { m_name = name; }

    // public members
    float height;
    unsigned int shoeSize;

    // member function
    bool hasBigFeet() const { return shoeSize > 10; } // U.K.!

private:
    std::string m_name;
};
PONDER_TYPE(Person)     // declare the type to Ponder

static void declare()   // declare the class members to Ponder
{
    ponder::Class::declare<Person>("Person")
        .constructor<std::string>()
        .property("name", &Person::name, &Person::setName)
        .property("height", &Person::height)
        .property("shoeSize", &Person::shoeSize)
        .function("hasBigFeet", &Person::hasBigFeet)
        ;
}
int main(){
    declare();
    const ponder::Class& metaclass = ponder::classByType<Person>();
    ponder::UserObject data = ponder::runtime::create(metaclass, "Tom");
    //auto value = data.get("m_value");
    //std::cout << value << std::endl;   
    //data.set("m_value", 1000);
    return 0;
}

I compiled the demo code but got the following error: undefined reference to `ponder::runtime::ObjectFactory::construct(ponder::Args const&, void*) const'

fish-king commented 3 years ago

niuwaniuwa

lamweilun commented 1 year ago

I am getting the same issue, anyone has any updates on this?