I want to set Libs: line via qmake .pro file and I try doing it like this:
LIBS += -ldl
to make my target executable be also linked with dl library because my library I am trying to link it with uses dl inside. However, this does not work, and qmake puts this string into Libs.private section instead which is not passed to gcc command line during compilation and so I am unable to produce an executable:
Libs.private: -ldl
while I want it to be in Libs: line like that:
Libs: -lmylibrary -ldl
I also can't find any references to QMAKE_PKGCONFIG_* variables anywhere in the web, is there any?
Is used for generating .pc files:
CONFIG += create_pc create_prl no_install_prl
By greping for QMAKE_PKGCONFIG_ I found the following in ~/5.12.0/clang_64/mkspecs/features/qt_module.prf
QMAKE_PKGCONFIG_DESTDIR
QMAKE_PKGCONFIG_LIBDIR
QMAKE_PKGCONFIG_INCDIR
QMAKE_PKGCONFIG_CFLAGS
QMAKE_PKGCONFIG_NAME
QMAKE_PKGCONFIG_FILE
QMAKE_PKGCONFIG_REQUIRES
QMAKE_PKGCONFIG_DESCRIPTION
QMAKE_PKGCONFIG_INSTALL_REPLACE
From the man page for pkg-config:
Libs.private:
This line should list any private libraries in use.
Private libraries are libraries which are not exposed through your library,
but are needed in the case of static linking.
This differs from Requires.private in that it references
libraries that do not have package files installed.
So i guess as long as you don't export them through your lib they will end up in Libs.private.
My Ubuntu has ffmpeg library in /usr/lib/x86_64-linux-gnu. I also rebuild ffmpeg from source and install it into my home directory.
In project file, I have added following lines:
TARGET = testFFmpeg
INCLUDEPATH += /home/kiet/ffmpeg/include
LIBS += -L/home/kiet/ffmpeg/lib/ -lavcodec -lavformat -lavutil -lswscale
I build my project successfully. But my binary file still links to ffmpeg in /usr/lib/x86_64-linux-gnu
ldd testFFmpeg | grep libav
libavcodec-ffmpeg.so.56 => /usr/lib/x86_64-linux-gnu/libavcodec-ffmpeg.so.56 (0x00007f9085ce7000)
libavformat-ffmpeg.so.56 => /usr/lib/x86_64-linux-gnu/libavformat-ffmpeg.so.56 (0x00007f90858e9000)
libavutil-ffmpeg.so.54 => /usr/lib/x86_64-linux-gnu/libavutil-ffmpeg.so.54 (0x00007f908567a000)
How can I ask qmake to find library in my folder first?
How can I ask qmake to find library in my folder first ?
Operator += adds the item to the end of the list, but you need to put it at the head of the list like this:
LIBS = stuff $$LIBS
I got opencv_contrib pack files from github https://github.com/Itseez/opencv_contrib
and built it successfully as the README says ,
$ cmake -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..
then I typed make install to generate .so files (Did I misunderstand this command here?) .
But when I use qt to compile this example docs.opencv.org/master/db/d56/tutorial_capture_graycode_pattern.html#gsc.tab=0
it comes error like
undefined reference to `cv::structured_light::GrayCodePattern::Params::Params()'
what should I do?
the following things I've added it in .pro
INCLUDEPATH += /home/tau/opencv/opencv-3.1.0/include /home/tau/opencv/opencv_contrib/modules/structured_light/include
LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_imgcodecs -lopencv_video -lopencv_videoio-lopencv_structured_light
I am newby in Qt, and try to compile tutorial application with MinGW. The only problem, that I need to put -gstab+ option to gcc compiler instead of -g option that qmake generated by default.
Currently, I select debug configuration (it add CONFIG += debug to the qmake command-line).
I've tried to add CONFIG += gstab+ to the .pro file, but it does not work. qmake generates makefile.Debug file with -g option.
What do I make wrong? And how should it be?
I've found a solution here http://qt-project.org/forums/viewthread/2412
I've added the following lines to my .pro file:
QMAKE_CXXFLAGS_DEBUG += "-gstabs+"
QMAKE_CFLAGS_DEBUG += "-gstabs+"
I'm new to Qt, I've done some Googleing and can't find a detailed enough answer.
I need to use OpenSSL in my qmake-based Qt project. How do I go about downloading/installing/linking it so I can just do an include statement and use its functions in my code?
Assuming Windows, you can download its installation from Win32 OpenSSL Installation Project page. You can choose one for 64-bit windows developing or for 32-bit. Just run the setup and everything will be done easily. The default installation directory is : C:\OpenSSL-Win32
In Qt creator, if you then want to link a library to your project you can just add this line to your .pro file(project file ) :
LIBS += -L/path/to -llibname
So here's what we do for this library( for example to link ubsec.lib )
LIBS += -LC:/OpenSSL-Win32/lib -lubsec
Pay attention to -L and -l.See this question. You don't even need to specify .lib at the end of the library name.
For including .h files add this line to your .pro file :
INCLUDEPATH += C:/OpenSSL-Win32/include
after that you can include a file like this :
#include <openssl/aes.h>
From George at Unable to use AES files of OpenSSL in Qt Creator:
If this is on Linux, add the following into your .pro file:
PKGCONFIG += openssl
It will handle all necessary header paths, compile-linker options and
the libraries.
And make sure you have the openssl-devel package installed in your
system.
I was working on Win 7 (32) with Qt5.5, and non of these answers worked for me.
So I just want to share a solution that finally worked:
1. I have OpenSSL installed in C:\OpenSSL-Win32
2. In c:\OpenSSL-Win32\MinGW there are two library files:
libeay32.a & ssleay32.a
3. I've made a copy of each of them an renamed the extensions:
libeay32.a -> libeay32.lib & ssleay32.a -> ssleay32.lib
4. I linked libraries in my .pro file this way:
LIBS += -LC:/OpenSSL-Win32/lib/MinGW -llibeay32
LIBS += -LC:/OpenSSL-Win32/lib/MinGW -lssleay32
INCLUDEPATH += C:/OpenSSL-Win32/include
5. I copied 3 .dll files from C:\OpenSSL-Win32:
(libeay32.dll, libssl32.dll, ssleay32.dll)
to my build/debug folder:
(build-XXXXX-Desktop_Qt_5_5_1_MSVC2012_32bit-Debug/debug)
I hope this will help.
If you use cmake as build system for your project, then you may include FindOpenSSL.cmake as follows:
#set(OPENSSL_USE_STATIC_LIBS TRUE) # if you want to use static libssl.a and libcrypto.a
include(FindOpenSSL)
#add_executable(${PROJECT_NAME} ...) or add_library(${PROJECT_NAME} ...)
target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_DL_LIBS} OpenSSL::SSL OpenSSL::Crypto)
${CMAKE_DL_LIBS} is required on Linux systems to avoid link-time errors like "dlopen symbol not found...". On windows it became empty.
If openssl installation directory is not being standard, then you should provide OPENSSL_ROOT_DIR to cmake, e.g. to add set(OPENSSL_ROOT_DIR "C:/msys64/mingw32") before include or to specify -DOPENSSL_ROOT_DIR:PATH=C:/msys64/mingw32 to cmake executable (in "Projects"->"Build settings"->"CMake" tab).
if you are on win7,and your qt version is mingw, and u install openssl from http://slproweb.com/products/Win32OpenSSL.html ,make sure your lib should be in the OpenSSL-Win32/lib/MinGW, and add a "lib" pre to the libeay32.a and ssleay32.a 。