Connecting to a Library In Linux
-
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!
-
You can use that feature yes.
-
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.
-
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.
@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.
-
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.
-
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?
-
You can use that feature yes.
-
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.
-
Not knowing anything of your code I would say you have gremlins in your screen :-)
-
@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.