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. Connecting to a Library In Linux

Connecting to a Library In Linux

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 1.1k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Currently, I am using the Ubuntu version of Linux and trying to build a project that uses the ZMQ library. I would like to implement cppzmq/libzmq to do this. For reference, here is how I installed both libzmq and cpp zmq (did both in the home directory):

    Install libzmq

    git clone https://github.com/zeromq/libzmq.git
    sudo apt-get update
    sudo apt-get install -y libtool pkg-config build-essential autoconf automake uuid-dev
    cd libzmq
    ./autogen.sh
    ./configure
    make
    make check
    sudo make install
    

    Install cppzmq

    git clone https://github.com/zeromq/cppzmq.git
    cd cppzmq
    mkdir build
    cd build
    sudo snap install cmake
    cmake ..
    sudo make -j4 install
    

    For Qt, I used the online installer from Qt's download page (https://www.qt.io/download-open-source?hsCtaTracking=9f6a2170-a938-42df-a8e2-a9f0b1d6cdce|6cb0de4f-9bb5-4778-ab02-bfb62735f3e5).

    Also Noted: I have been able to successfully create Server/Client standalone ZMQ programs that work. Now, I just want to implement the client side in a qt app.

    Before I get started on this ZMQ project, I was wondering how I need to add the ZMQ library to ensure the program works; also, will using the #include zmq.hpp statement suffice, or will I need to write other statements in my program code? Thank you!

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

      You can use that feature yes.

      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
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        Qt is a C++ framework so using other libraries with it is the same as any other C++ project.

        That said, I remember there was some project to integrate ZMQ with Qt's event loop. You might want to check that.

        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
        • SGaistS SGaist

          Hi,

          Qt is a C++ framework so using other libraries with it is the same as any other C++ project.

          That said, I remember there was some project to integrate ZMQ with Qt's event loop. You might want to check that.

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #3

          @SGaist Thank you for your quick response; Sorry if it seems like I'm having a tough time, but I don't have any experience with linking libraries (first time I've done this on a Qt project). Would I need to edit the project file, insert one of the files from the zmq library, or doing something entirely different? Once again, thank you for your help.

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

            Are you going to use qmake or cmake to handle your project ?

            In any case, the concept will be the same:

            • set the path to the includes of the library
            • set the path to the folder where the library file can be found
            • link to the library

            The first two are required if the files are in a non conventional location.

            CMake and qmake both have different ways to do it.

            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
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #5

              Using qmake; Would I use the "add library" option that shows when I right click the project name, or do I need to do linking manually in the .pro file?

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

                You can use that feature yes.

                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
                • SGaistS SGaist

                  You can use that feature yes.

                  ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #7

                  @SGaist

                  Screen Shot 2021-10-19 at 2.21.44 PM.png

                  So I went in and manually added the "LIBS" line instead of using the "Add Library Feature." Should this be enough? I didn't get any compilation errors but when I tried to run the program I built the entire window was just a black screen.

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

                    Not knowing anything of your code I would say you have gremlins in your screen :-)

                    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
                    • C Offline
                      C Offline
                      ChrisW67
                      wrote on last edited by
                      #9

                      @WesLow If your program uses functions from libzmq. compiled. and linked cleanly then the linker options are OK (but possibly not perfect). If you built and installed libzmq as you describe then the result is installed under /usr/local/bin, lib etc. The "-L" part of your LIBS variable is wrong but is possibly not required because /usr/local/lib will often be searched by default.

                      If the black screen is from your running program then that is a different problem.

                      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