Can't link qwt in Qt - qt

I use LIBS flag to link qwt library to my project. So in .pro of my project i have
LIBS += -L/home/Desktop/qwt-6.0.1/lib -lqwt
But anyway Qt does not recognize qwt classes. What i'm missing ??

I think you forgot to include the headers.
Try to add the following
INCLUDE += /home/Desktop/qwt-6.0.1/include

I had same problem. you have to use -L switch and set your library path as bellow:
LIBS+= -L "/home/Desktop/qwt-6.0.1/lib/" -lqwt
adding above line to the .pro file resolve compiling error of the project. then for running Application you should link libqwt.so.6.1.3 to default library path on your system using bellow command:
ln -s /home/Desktop/qwt-6.0.1/lib/libqwt.so.6.1.3 /usr/lib/libqwt.so.6
or simply update LD_LIBRARY_PATH using below command:
export LD_LIBRARY_PATH=/home/Desktop/qwt-6.0.1/lib/lib:$LD_LIBRARY_PATH
I advice you to use the first approach.

Related

Can I set a standard path to Qt-directory in a .pro file?

is there a way to define the path to the qt directory in a .pro file?
I've tried INCLUDEPATH += and LIB += but after qmake in the makefile always stands /usr/share/qt4 and /usr/include/qt4/ for the path to the directory where qt is installed... Maybe I could say I want to replace /usr/ with /home/ubuntu/Qt5.2.1/5.2.1/gcc or some other stuff.
What #Linville says is right. Use the correct qmake and those paths will be what you want.
Generally you should not need to set QTDIR and just running the correct qmake should work.
eg
export PATH=/home/ubuntu/Qt5.2.1/5.2.1/gcc/bin:$PATH
mkdir -p $HOME/build/myapp && cd $HOME/build/myapp
# check you have the right qmake
which qmake && qmake -query
# shadow build so as to not pollute your source tree
qmake $HOME/source/myapp/myapp.pro
If for some reason you want to refer to the paths listed by qmake -query you can use $$[QT_INSTALL_DATA] for example.
I have issue with header file not found, so I used export path before qmake which solved my problem.

Install and use QWT under Mac OS X

I am currently trying to get QWT 6.1.0 running under MAC OS X 10.7.5.
I followed the instructions over here --> http://qwt.sourceforge.net/qwtinstall.html
I didn't changed something inside the configuration files.
So everything worked fine, but now I want to use the qwt-libary inside my own Project.
I added the following line to my .pro
INCLUDEPATH += /Users/userX/Downloads/qwt-6.1.0/src
So my Project is now able to find all the header Files.
But I also have to link against the libary. But I dont know how to do so.
I tried using something like this:
LIBS += -L /usr/local/qwt-6.1.0/lib -lqwt
But than I get an error called "libary not found for -lqwt".
What I am doing wrong?
How can I link against the library or how could I import the qwt framework into my project?
I found a solution.
Here is a step by step guide on how to install QWT 6.1.0 under Mac OS X and get it running inside the QT-Creator :
Download the .tar.bz2 from here http://sourceforge.net/projects/qwt/files/qwt/6.1.0/
Extract it where you want, for Example inside your Download-Folder
Then change into the directory qwt-6.1.0
Then you have to locate the qmake command line tool ( you can do so by simply searchng for it inside the Finder.
Then qmake the qwt.pro File like /Applications/QT/5.1.0/clang_64/bin/qmake qwt.pro
make
sudo make install
Inside your QT Project you have to add the following line to the
.pro File include ( /usr/local/qwt-6.1.0/features/qwt.prf )
includes QWT libary into Project
Now you have to create a softlink like this : sudo ln -s
/usr/local/qwt-6.1.0/lib/qwt.framework/qwt /usr/lib/qwt
Thats it. QWT now should work.
UNDER MAVERICKS:
If you are using Mavericks you have to manually copy the qwt.framework to Libary/Frameworks folder for not getting the "dyld: Library not loaded: libqwt.6.dylib" error .. i dont know why but it works.
Download the .tar.bz2 from here
Extract it where you want, for Example inside your Download-Folder
Then change into the directory qwt-6.1.4 (Example: mac:~ Apple$ cd downloads/qwt-6.1.4)
Then qmake the qwt.pro (Example: mac:~ Apple$ /Users/(your name)/documents/qt/5.12.5/clang_64/bin/qmake qwt.pro)
mac:~ Apple$ make
mac:~ Apple$ sudo make install
Inside your QT Project you have to add the following line to the
.pro insert this line: "include ( /usr/local/qwt-6.1.4/features/qwt.prf )" without quotes
Now you have to create a softlink like this: mac:~ Apple$ sudo ln -s/usr/local/qwt-6.1.4/lib/qwt.framework/qwt /usr/lib/qwt
If you have this error:
dyld: Library not loaded: qwt.framework/Versions/6/qwt
Referenced from: /Users/Desktop/build-check5-Desktop_Qt_5_12_5_clang_64bit2-Debug/check5.app/Contents/MacOS/check5
Reason: image not found
For MacOs Mojave you must copy qwt.framework to the Library/Frameworks folder.

How to Include OpenSSL in a Qt project

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 。

how can I write (#include <libnotify/notify.h> ) without errors?

I want to apply the simple notification example in the following link
http://www.developer.nokia.com/Community/Wiki/How_to_use_standard_Maemo_5_notifications_in_Qt_applications
I followed the steps and added the 2 lines in .pro
CONFIG += link_pkgconfig
PKGCONFIG += libnotify
but I have the following error when I write #include <libnotify/notify.h>
error: libnotify/notify.h: No such file or directory
Isn't this missing in your .pro file?
INCLUDEPATH += /path_to/libnotify
where path_to is either absolute path like this or relative to directory where your .pro file resides.
Sound like you simply don't have libnotify installed.
Don't know what distro you're using, but something like pacman -S libnotify, apt-get install libnotify, etc. should work.

How can I set where a Qt app finds a Qt module?

I would like to include libQtGui.so.4 libQtNetwork.so.4 and libQtCore.so.4 in the same directory as where my app resides. How would I make Qt understand this? y purpose is to have a standalone app that uses shared libraries
Setting the LD_LIBRARY_PATH environment variable is one option. For example:
export LD_LIBRARY_PATH=/path/to/dir/with/libs:$LD_LIBRARY_PATH
Another option is to set the RPATH of your Qt application during linking. Setting the RPATH to the value "$ORIGIN" will cause the dynamic linker to look in the same directory as your Qt application at runtime. For example, if using qmake, add the following snippet to your project file:
unix:!mac{
QMAKE_LFLAGS += -Wl,--rpath=\\\$\$ORIGIN
QMAKE_LFLAGS += -Wl,--rpath=\\\$\$ORIGIN/lib
QMAKE_LFLAGS += -Wl,--rpath=\\\$\$ORIGIN/libs
QMAKE_RPATH=
}
This will set the RPATH to "$ORIGIN:$ORIGIN/lib:$ORIGIN/libs", meaning that the dynamic linker will first look in the location of your Qt application, then in a lib subdirectory at its location, then in a libs subdirectory at its location, and finally in any system defined locations.
UNIX / Linux is going to look in LD_LIBRARY_PATH (if set) first before looking in the system standard libs. So if you set that, you can indeed override. Just like setting the PATH on Windows. Same effect. The ordering matters.
You can add ./ or . to LD_LIBRARY_PATH as well.
export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
LD_LIBRARY_PATH and QMAKE_RPATH never worked for me. Instead, I set QMAKE_RPATHDIR in my .pro file. For example after having built and installed (make install) Qt, it has been placed in /usr/local/Trolltech/Qt-4.8.5/lib/. I then write the following in my .pro file:
QMAKE_RPATHDIR += /usr/local/Trolltech/Qt-4.8.5/lib/
Note 1: Relative paths seem not to work. Prefer absolute paths.
Note 2: When you then make, you can see that the following option is given to the linker: -Wl,-rpath,/usr/local/Trolltech/Qt-4.8.5/lib/
Note 3: To be sure that the binary links dynamically to the correct library, you can display the version of Qt at runtime delivered by qVersion().

Resources