Installing libusb on windows for use with Qt - c++

I'm trying to install libusb (not libusb-win32) on windows 7. I have to link it with Qt 5.0.1. Here are the problems I'm facing
In the INSTALL file in the extracted libusb folder, it tells me to cd to the current folder then run
./configure
make
makeinstall
But I got the error
'./configure' is not recognized as a valid command.
Googling this problem usually gives the solution as installing libusb-win32. However, I want to avoid that, as of now.
In the libusb library, there were a few MSVC projects, so I built them. That did generated some .lib files. So I proceeded to link them with my Qt project. It recognizes the libusb.h header file but does not link properly. Here is my .pro file
QT += core gui widgets
TARGET = Qt_libusb TEMPLATE = app
SOURCES += main.cpp\
qt_libusb.cpp
HEADERS += qt_libusb.h
FORMS += qt_libusb.ui
LIBS += -LC:\libusb-1.0.18\Win32\Debug\lib\libusb-1.0
INCLUDEPATH += C:/libusb-1.0.18/libusb DEPENDPATH += C:/libusb-1.0.18/libusb
My objective is to link the libusb library with Qt. Please tell me if I haven't 'installed' the library correctly or if I am linking it in a wrong way. thanks

Your project file does not reference the library. You only provide a path where libraries might be found, but there's no reference to the libusb library itself.
What you're missing is something like
LIBS += -llibusb
You also can't have multiple project file statements on the same line. The below is an error:
TARGET = Qt_libusb TEMPLATE = app
It should look like:
TARGET = Qt_libusb
TEMPLATE = app

Related

How to link QCA to my Qt project?

I have successfully cloned git repository of QCA and built it using
cmake .
make
sudo make install
This created bin directory with some executables and I can confirm everything works as should by running
$ bin/qcatool-qt5 plugins
/usr/lib/x86_64-linux-gnu/qt5/plugins
/home/metheuser/qtcreator/qca/bin
Available Providers:
qca-gnupg
qca-logger
qca-ossl
This product includes cryptographic software written by Eric Young
(eay#cryptsoft.com)
qca-softstore
However when I specify in my Qt project:
QT += crypto
I get this error
Unknown module(s) in QT: crypto
I have no idea how to include the library now. I have tried adding this to my .pro file:
LIBS += -lqca
and
LIBS += -lqca2
Both resulting in error:
cannot find -lqca
What should I do? I followed the official README/INSTALL instructions.
you need to add the lib path to your .pro file. So, Instead of
LIBS += -lqca
you need
LIBS += -L$${PATH_QCA_LIB} -lqca

Bind Qt with QtGStreamer

I am trying to make a simple qt c++ VoIP application, when I searched I found the QtGStreamer Lib and wanted to make it work. I download the latest version 1.2 from here.When I went to the example folder and tried to compile the VoIP example I got this error:
Qt5GStreamer-1.0 development package not found
What I try is comment this line CONFIG += link_pkgconfig in .pro file and add the src folder that came with the folder of QtGstreamer to folder project. I also added this to .pro file INCLUDEPATH += $$PWD/src this the path of the Libs folder
Now I get an error that i need to add boost Lib so I add it by adding this to .pro file
INCLUDEPATH += C:/boost_1_61_0
LIBS += "-LC:/boost_1_61_0/stage/lib"
Now I get many errors that say (undefined reference to ..) 130 error. Not sure what to try.
the file comes with containing Readme file I download the dependency but the same error I think the problem that I don't link it correctly I'm still a beginner in 3rd party and link libs in c++,
my os is windows
Thanks in advance

How to create Qt executable for linux machines

I have created a project using Qt 5.3. I want this project to be executable on other linux machines, so I took the executable file which is generated in the build folder of the project and executed it on the other linux machine. When I did that I got the following error:
./Project_name: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
I developed the application using QT 5.3 but the linux machine where I am trying to execute it has libqt4 libraries. Is there any way for this file to be executable using the libqt4 libraries only.The following is my .pro file of the project:
#-------------------------------------------------
#
# Project created by QtCreator 2014-12-08T09:19:31
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Project_name
TEMPLATE = app
QMAKE_CXXFLAGS += -std=c++11
SOURCES += main.cpp\
mainwindow.cpp \
INCLUDEPATH += /usr/include/python2.7/
HEADERS += mainwindow.h
FORMS += mainwindow.ui
I checked online and found out that we need to make changes in the "greaterThan(QT_MAJOR_VERSION, 4): QT += widgets" so that it works for qt4 libraries. I did that but it did not work. So could you let me know what could be done so that the project which is built using libqt5 can also be executed on machines which have libqt4. Installing libqt5 libraries can be done but I am looking for a way other than that.
Is there any way for this file to be executable using the libqt4 libraries only
Not easily at least... Even if you created symlinks, Qt 4 and Qt 5 are not binary compatible.
If you want to make it self-contained:
bundle the libraries statically.
Use dynamic symbol loading and based on the version you find, you may need to program the code to act differently. But it may be a hell lot of work.
hey make sure libqt5widgets are installed on your system and you are using the correct qmake (version 5x in your case) you can installl them on debian based distro by issuing the command or via Synaptic package manager
sudo apt-get install libqt5widgets5

Error compiling C++ program against GeoIP library

I'm trying to compile a simple program using the GeoIP2 lite API. I've compiled the GeoIP Lite program and it created the library files. The .la file is in /mydir/libmaxminddb-0.5.3/src
I modified my .pro file to include:
LIBS += /mydir/libmaxminddb-0.5.3 -lmaxminddb
but when I compile my project errors with "Cannot find -lmaxminddb"
Can someone tell me what's wrong? I've tried changing directories, adding a "lib" prefix to the maxminddb, and more, but I can't figure it out.
(I'm trying to link against libmaxminddb.a which is pointed to by libmaxminddb.la)
I believe in autoconf and friends the -l flags go in the LDFLAGS variabe, not LIBS.
I found elsewhere that with Qt Creator you can right click the project and add an external library. When I do so, I see the .pro file adds:
LIBS
INCLUDEPATH
DEPENDPATH
So that's what you need to add!
That should be LIBS += -L/mydir/libmaxminddb-0.5.3 -lmaxminddb. Note the extra -L in front of the directory name.

linking mac framework to qt creator

I have a project that uses SystemConfiguration.Framework.
I've been using xcode, where adding the framework is quite easy, just add it to xcode project's framework. But now, I need my project to be cross platform, so I'm using QT Creator as a single IDE, for Windows and Mac. The problem is that I don't know how to tell QT Creator how to link to the systemConfiguration.framework. The header from the framework are correctly included, no problem there... just when is ending the compilation it complains that some symbols where not found, i.e, the symbols that are exported from the systemconfiguration.framework...
Does anyone knows or can help me to set up the Qt creator project to link agains that framework, please?
I assume the project itself is using Qt i.e. it is using .pro files to configure things like include paths and library/framework paths? If so then you just need to update the relevant .pro file to add the framework.
See the qmake docs for more detail. The gist of it is to add
QMAKE_LFLAGS += -F/path/to/framework/directory/
and
LIBS += -framework TheFramework
I found a solution which works with Qt 5.6 here:
https://doc.qt.io/qt-5/qmake-platform-notes.html#creating-frameworks
Using Frameworks
qmake is able to automatically generate build rules for linking
against frameworks in the standard framework directory on macOS,
located at /Library/Frameworks/.
Directories other than the standard framework directory need to be
specified to the build system, and this is achieved by appending
linker options to the LIBS variable, as shown in the following
example:
LIBS += -F/path/to/framework/directory/
The framework itself is linked in by appending the -framework options and the > name of the framework to the LIBS variable:
LIBS += -framework TheFramework