Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. [SOLVED] Utilising libgcal-0.9.6 to work with Google Calendars
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Utilising libgcal-0.9.6 to work with Google Calendars

Scheduled Pinned Locked Moved 3rd Party Software
3 Posts 2 Posters 1.3k Views 1 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
    mikeosoft
    wrote on last edited by
    #1

    I'm having a problem adding a library to work with and compile into my program.

    I'm working on Linux Mint 17 64bit and I am using:
    Qt Creator 3.1.2 (opensource)
    Qt 5.3.1 (GCC 4.6.1 64 bit)

    I am wanting my program to be able write an appointment made in a calendar widget that I have written, as a child class of QCalendarWidget to the/my Google Calendar. The appointment is also stored in a local database.

    I have downloaded and build libgcal-0.9.6, following the instructions; dealing with the dependences and in seems to have installed correctly.

    Initially I included my own LIBS and INCLUDEPATH statements in the profile, but when that didn't work I tried the right-click and Add library... option in Qt Creator, which just results in the same error. My additions occour first and the generated ones appear second with all the extra parent folder steps.

    I have included the majority of my profile, excluding all the Source and Header file inclusions; below and the source code which generates the errors, which is virtually the example code provided, but with a couple of modifications to make it work within my program. The errors relate to the compilation or rather the linking rather than problems in the code.

    The Profile:
    @QT += core gui
    QT += sql
    QT += network
    QT += xml
    QT += printsupport

    CONFIG += qt warn_on
    CONFIG += c++11

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    unix {
    INCLUDEPATH += "/home/mike/hunspell-1.3.3/src/hunspell"
    LIBS += /usr/local/lib/libhunspell-1.3.so

    INCLUDEPATH += "/usr/local/include/libgcal"
    LIBS += "/usr/local/lib/libgcal.so"
    

    }

    win32 {
    INCLUDEPATH += C:/path/to/hunspell/include
    LIBS += C:/path/to/hunspell/Release/hunspell.lib
    }

    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../usr/local/lib/release/ -lgcal
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../usr/local/lib/debug/ -lgcal
    else:unix: LIBS += -L$$PWD/../../../../../usr/local/lib/ -lgcal
    INCLUDEPATH += $$PWD/../../../../../usr/local/include/libgcal
    DEPENDPATH += $$PWD/../../../../../usr/local/include/libgcal@

    The Source code:
    @bool Appointment_Editor_Dialog::add_GoogleCal()
    {
    bool retval(false);
    char name[28] = "johnsmith@googlemail.com";
    char pass[14] = "***********";

    gcal_t gcal;
    gcal_event_t event;
    int result;
    
    /* Create a gcal 'object' and authenticate with server */
    if (!(gcal = gcal_new(GCALENDAR)))
            exit(1);
    

    // if (argc == 3)
    // result = gcal_get_authentication(gcal, argv[1], argv[2]);
    // else
    result = gcal_get_authentication(gcal, name, pass );

    /* Create an event 'object' and fill in some data */
    if ((event = gcal_event_new(NULL))) {
            gcal_event_set_title(event, ui->lineEdit_Title->text().toUtf8());
            gcal_event_set_content(event, "Here goes the description");
    
              QString temp_start(ui->dateEdit_Start->date().toString("yyyy-MM-dd"));
            temp_start += "T";
            temp_start += ui->timeEdit_Start->time().toString("HH:mm");
            temp_start += ":00Z";
    
    
            QString temp_end(ui->dateEdit_End->date().toString("yyyy-MM-dd") + "T" + ui->timeEdit_End->time().toString("HH:mm") + ":00Z");
    
            gcal_event_set_start(event, temp_start.toStdString().c_str());
            gcal_event_set_end(event, temp_end.toStdString().c_str());
            gcal_event_set_where(event, "A nice place for a meeting");
    }
    
    /* Add a new event */
    if (!(result = gcal_add_event(gcal, event))) {
    
            /* Edit this event */
            gcal_event_set_title(event, "Changing the title");
            result = gcal_update_event(gcal, event);
    
            /* Delete this event (note: google doesn't really deletes
             * the event, but set its status to 'cancelled' and keeps
             * then for nearly 4 weeks).
             */
            result = gcal_erase_event(gcal, event);
    }
    
    /* Cleanup */
    gcal_event_delete(event);
    gcal_delete(gcal);
    return(retval);
    

    }@

    This code was to prove it worked, I'll worry about the quality of the code once I have the library working (though feel free to make suggestions); I wasn't intending to hard code the email address and pass word in to the code.

    Samples of the errors are a list below (though one occours for every library function called:
    @undefined reference to 'gcal_new(gservice)'
    undefined reference to 'gcal_get_authentication(gcal_resource*, char*, char*)'
    undefined reference to `gcal_event_new(char*)'@

    The two declarations at the start don't generate any errors:
    @
    gcal_t gcal;
    gcal_event_t event;
    @

    These occur for every function within the library used within the method.

    GCC seems to be finding the Header file and the Library, but not the functions within them, if I change the path to make it not find them the errors I get are different, which suggests it is finding the files.

    As I was writing this it occurs to me that the version of gcc used elsewhere on my system is 4.8.2, if that is the problem, how do I get the library compiled by the right version? I recently added hunspell, following a similar process and didn't have these problems.

    Any suggestions welcome.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      Is libgcal a C-library ?
      If so do the header files have extern "C" around their function declarations?
      If not then you may need to put extern "C" around includes.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mikeosoft
        wrote on last edited by
        #3

        libcal is a c library, so adding the following around the header made it work

        @extern "C" {
        #include <gcalendar.h>
        }@

        Thank you very much for your help, it's appreciated.

        Mike

        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