Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Grantlee
Qt 6.11 is out! See what's new in the release blog

Grantlee

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.5k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Monster_Inc
    wrote on last edited by Monster_Inc
    #1

    Hi there,

    has anybody experience compiling with Grantlee on Ubuntu?
    libgrantlee-dev is installed and auto-completion in QtCreator works fine, however I do not manage to get the example to build:

    #include <grantlee_core.h>
    #include <grantlee_templates.h>
    #include <grantlee/engine.h>
    #include <grantlee/template.h>
    #include <grantlee/context.h>
    #include <grantlee/variable.h>
    
    int main(int argc, char *argv[])
    {
        Grantlee::Engine *engine = new Grantlee::Engine( 0 );
        Grantlee::Template t = engine->newTemplate("My name is {{ name }}.", "my_template_name");
        QVariantHash mapping;
        mapping.insert("name", "Grainne");
        Grantlee::Context c(mapping);
        t->render(&c); // Returns "My name is Grainne."
        mapping.insert("name", "Henry");
        c = Grantlee::Context(mapping);
        qDebug() << t->render(&c); // Returns "My name is Henry."
    

    qmake && make results in:
    undefined reference to `Grantlee::Engine::Engine(QObject*)'
    and many other undefinded-reference-errors, as I've missed some includes.

    Any ideas?
    Thanks in advance

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Monster_Inc said:
      Hi and welcome
      Since it is a extern lib, I assume you must
      add it to the .pro file
      something like
      LIBS += -L/path/tolib -lgrantlee

      often the L part is
      /usr/local/lib
      LIBS += -L/usr/local/lib -lgrantlee
      but should point to where the lib is.

      If its not linking errors, you get you might need to add the include
      path to the pro file also

      HEADERS += mainwindow.h
      path to folder with grantlee

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved