Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Libjson Library
QtWS25 Last Chance

Libjson Library

Scheduled Pinned Locked Moved Installation and Deployment
11 Posts 2 Posters 4.8k Views
  • 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.
  • D Offline
    D Offline
    darkp03
    wrote on last edited by
    #1

    Hi everyone!

    Im trying to compile a project ive found on internet, and im having a really bad time, with libraries I currently not have.

    First of all, im running Windows 7 32 bit, with MinGW 4.8.2 32 bit and Qt 4.8.6. Im using this old version of Qt because it was the version the project was created with, and when I tried to compile it with the latest Qt, I had even more trouble.

    The project has a libs-windows folder, that originally comes empty. When you compile it, it gives you errors like

    bq. ../kiax2core/libs-windows/libjson.a: No such file or directory

    Among others, Im mentioning this one because its the library I havent been able to get my hands on, (the rest I easily found them on the internet). First of all... Isnt the .a extension supposed to be for Linux? The project comes for either Linux, Windows or Mac, but im certain that ive placed the correct defines and commented the correct parts to specify im running it on windows.

    Im going to explain what I did, so you guys can tell me what im doing wrong.

    First of all, ive downloaded the latest version of libjson from here
    http://projects.snarc.org/libjson/download/
    Unfortunately, theres no libjson.a file in here. But theres a makefile. As I have currently a virtual machine running Fedora, with make, I passed the library to Fedora, ran make, and got the libjson.a file, among others. When I place the libjson.a file into the folder where its supposed to be, I start getting undefined references to functions that are clearly from this library, for example

    bq. undefined reference to “json_tokener_parse”
    undefined reference to “json_object_object_get”
    undefined reference to “json_object_get_int”
    undefined reference to “json_object_get_string”

    This library doesnt seem to be working... Id like to mention, that, on the project folders, I can find kiax2core->includes->json

    Inside this folder I have the following files:

    arraylist.h
    bits.h
    debug.h
    json.h
    json_object.h
    json_object_private.h
    json_tokener.h
    json_util.h
    linkhash.h
    printbuf.h

    All of them are included on the project, but they dont work. The json.h for example only has the following code inside

    @/*

    • $Id: json.h,v 1.6 2006/01/26 02:16:28 mclark Exp $
    • Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
    • Michael Clark michael@metaparadigm.com
    • This library is free software; you can redistribute it and/or modify
    • it under the terms of the MIT license. See COPYING for details.

    */

    #ifndef json_h
    #define json_h

    #ifdef __cplusplus
    extern "C" {
    #endif

    #include "bits.h"
    #include "debug.h"
    #include "linkhash.h"
    #include "arraylist.h"
    #include "json_util.h"
    #include "json_object.h"
    #include "json_tokener.h"

    #ifdef __cplusplus
    }
    #endif

    #endif
    @

    When I built it on fedora, i got a json.h with much more stuff into it, so i tried appending it to this small json.h, and i also tried replacing it, with no luck. I know im an extreme begginer with libraries and linking stuff, my guess is that im doing everything absolutly wrong. So could someone point me to a page where explains me what I should be doing, or at least give me a few guidelines?

    Thanks in advance!
    Regards,
    Nicolas

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

      Hi,

      You can't use libraries built on linux on windows (unless you cross-compiled them for windows)

      Since you are using MinGW, why not run mingw32-make in the libjson folder ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • D Offline
        D Offline
        darkp03
        wrote on last edited by
        #3

        That was my original idea, but i couldnt get mingw32-make to work.
        I have the mingw that got installed on the Qt bundle, and theres no mingw32-make at all. Ive downloaded one from here
        http://sourceforge.net/projects/mingw/files/MinGW/Extension/make/
        but when I try to use it it tells me its missing libintl-8.dll, and that I should reinstall the application.

        Is there any plugin or addon I should add to my Mingw installation to make the "make" work?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          IIRC Qt 4 doesn't come with MinGW it's the Qt 5 installer that provides it (but you can use it for both)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • D Offline
            D Offline
            darkp03
            wrote on last edited by
            #5

            Ok, I completly uninstalled my MinGW, and downloaded it again, with all the additional stuff I could select. This time it came with the mingw32-make, and I was able to build the library perfectly, yet it still gives the same errors.

            First of all, I just copied the libjson.a to the library folder, it didnt work.
            Then, I simply included all the files that I obtained by building the library, and I Manually added them to the project, still with the same results.
            These files are:
            json.c
            json.g
            json.o
            jsonlint.c
            jsonlint.o
            libjson.a
            libjson.pc
            libjson.pc.in

            Im having the "undefined reference to 'function name' "error, with functions that are from libjson. Whats weird, is that I cant find myself these functions.

            For example, I have the following error:

            bq. undefined reference to 'json_tokener_parse(char*)'

            This function is declared on json_tokener.h (a file that came with the project im trying to compile), and that I included on the same file where im having the error, just in case.

            Its declared on the following way

            @extern struct json_object* json_tokener_parse(char *str);@

            So that means that the "Body" of the function must me somewhere. I did a string search, using cmd, and the command findstr. I first placed myself on the project directory, and typed
            @findstr /s /i /p /c:"tokener_parse" .@

            And from all of the results, none of them where the function itself, only places where this function is called. So indeed, these functions are missing, but my question is... Where are them?
            I clearly dont understand something about how to compile libraries, and how they should work. Could someone point me in the right direction? Im going to sum up what I did so far

            1. I downloaded Libjson library from http://projects.snarc.org/libjson/download/

            2. I fixed my MinGW, by uninstalling it and installing it again, with all optional stuff checked.

            3. I opened a cmd window, placed myself on the library directory (where i can find a makefile) and made the mingw32-make, the libjson.a appeared

            4)I placed the libjson.a where my Qt program was looking for it, and rebuilt the project. Now it could find the library, but started giving me the undefined reference to "function name".

            1. I copied and pasted all of the files (that I listed before) to my project directory, and from QtCreator right clicked on the project, and went to add files, and added all of them. Rebuilt. Still same error

            Thats a summary of what ive tried, with no luck so far... What am I doing wrong? How does sombody usually add a library to a project? Which files should i add in the .pro file and what #includes should I place?

            Thanks in advance!

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Since you built it successfully on Fedora, check where does their libjson come from.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • D Offline
                D Offline
                darkp03
                wrote on last edited by
                #7

                I dont understand that, ive managed to build the library succesfully both on windows and on fedora, but i never got it working on my project

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Ok then, can you show your pro file ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    darkp03
                    wrote on last edited by
                    #9

                    @template = app
                    CONFIG += qt
                    CORELIBDIR = ../kiax2core
                    INCLUDEPATH += $$CORELIBDIR $$CORELIBDIR/includes $$CORELIBDIR/includes/json $$CORELIBDIR/dottelutils

                    set USEWEBKIT to true if you want to link to webkit shared library

                    USEWEBKIT = false

                    win32 {
                    LIBSDIR += $$CORELIBDIR/libs-windows
                    LIBS += $$LIBSDIR/iaxclient.dll $$LIBSDIR/sqlite3.dll $$CORELIBDIR/release/libkiax2core.a $$LIBSDIR/libjson.a $$LIBSDIR/libcurl-4.dll -leay32 -lssleay32
                    LIBS+= -LC:/OpenSSL-Win32/lib/MinGW
                    LIBS+= -LC:/OpenSSL-Win32/lib
                    DEFINES += WIN32DEP
                    }

                    KIAXOPT += dottel

                    contains( KIAXOPT, dottel ): {
                    message("Enabling dottel support..")
                    DEFINES += USE_DOTTEL
                    HEADERS += Kiax2DotTelDialog.h
                    ../kiax2core/dottelutils/dottelutils.h
                    ../kiax2core/dottelutils/CppDotTelutils.h
                    SOURCES += Kiax2DotTelDialog.cpp

                    FORMS += dotteldialog.ui

                    INCLUDEPATH += voip/ldns-1.4.0

                    win32 {
                    LIBS += $$LIBSDIR/libldns.a -lwsock32 -liphlpapi
                    }
                    }

                    comment if you don't have hold() in your iaxclient

                    DEFINES += IAXCLIENT_HOLD_HACK

                    QT += network
                    contains( KIAXOPT, webforms ): {
                    message("Using Webforms + WebKit..")
                    QT += webkit
                    DEFINES += USE_WEBFORMS
                    HEADERS += Kiax2ChangePassDialog.cpp
                    Kiax2RegisterDialog.h
                    SOURCES += Kiax2ChangePassDialog.cpp
                    Kiax2RegisterDialog.cpp
                    }

                    contains( KIAXOPT, webfeed ): {
                    message("Using Webfeed + WebKit..")
                    QT += webkit
                    DEFINES += USE_WEBFEED
                    }

                    FORMS += kiax2windowAlt.ui
                    accountdialog.ui
                    aboutdialog.ui
                    calldialog.ui
                    contactdialog.ui
                    contactlistitemwidget.ui
                    settingsdialog.ui
                    registerdialog.ui
                    loginscreen.ui

                    HEADERS += Kiax2MainWindow.h
                    Kiax2AboutDialog.h
                    Kiax2AccountDialog.h
                    Kiax2CallDialog.h
                    Kiax2ContactDialog.h
                    Kiax2ListWidgetItem.h
                    Kiax2ContactListItemWidget.h
                    Kiax2SettingsDialog.h
                    IAX2CallbackHandlerQt.h
                    Kiax2ConnectionMeter.h
                    Kiax2JSONBalance.h
                    Kiax2LoginScreen.h
                    Kiax2Application.h
                    Kiax2JSONUsersOnline.h
                    kiax2JSONNotification.h
                    Kiax2JSONServers.h
                    Kiax2DispatcherServer.h
                    Kiax2DispatcherThread.h
                    Kiax2Servers.h
                    Kiax2JSONSupernode.h
                    Kiax2CallAppearance.h
                    Kiax2CallDialogView.h
                    Kiax2CallButton.h
                    ../kiax2core/PConfiguration.h
                    Flashiadas/json.h

                    SOURCES += Kiax2MainWindow.cpp
                    Kiax2AboutDialog.cpp
                    Kiax2AccountDialog.cpp
                    Kiax2CallDialog.cpp
                    Kiax2ContactDialog.cpp
                    Kiax2ListWidgetItem.cpp
                    Kiax2ContactListItemWidget.cpp
                    Kiax2SettingsDialog.cpp
                    IAX2CallbackHandlerQt.cpp
                    Kiax2ConnectionMeter.cpp
                    Kiax2JSONBalance.cpp
                    Kiax2LoginScreen.cpp
                    Kiax2Application.cpp
                    Kiax2JSONUsersOnline.cpp
                    Kiax2JSONNotification.cpp
                    Kiax2JSONServers.cpp
                    Kiax2DispatcherServer.cpp
                    Kiax2DispatcherThread.cpp
                    Kiax2Servers.cpp
                    Kiax2JSONSupernode.cpp
                    Kiax2CallAppearance.cpp
                    Kiax2CallDialogView.cpp
                    Kiax2CallButton.cpp
                    Flashiadas/json.c
                    Flashiadas/jsonlint.c

                    RC_FILE = kiax2.rc

                    TRANSLATIONS = kiax2_fr.ts
                    kiax2_de.ts
                    kiax2_es.ts

                    build_all:!build_pass {
                    CONFIG -= build_all
                    CONFIG += release windows
                    }

                    install

                    target.path = .
                    sources.files = $$SOURCES $$HEADERS $$FORMS *.pro
                    sources.path = .
                    INSTALLS += target

                    OTHER_FILES +=
                    ../kiax2core/libs-windows/libjson.a
                    Flashiadas/json.o
                    Flashiadas/jsonlint.o
                    Flashiadas/libjson.a
                    Flashiadas/libjson.so
                    Flashiadas/libjson.so.0
                    Flashiadas/libjson.so.0.8
                    Flashiadas/libjson.so.0.8.0
                    Flashiadas/libjson.pc
                    Flashiadas/libjson.pc.in
                    @

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Are you sure $$LIBSDIR/libjson.a is correct ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        darkp03
                        wrote on last edited by
                        #11

                        Probably it isnt, that kind of the point in here. I got that libjson.a after compiling with mingw (mingw32-make) the library Ive downloaded from internet from here http://projects.snarc.org/libjson/download/
                        Im not sure if it doesnt work because the file is incorrect, or if i should be adding something else to the folder... a .h or .o maybe?
                        Are the steps I made incorrect?

                        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