How can I compile and run Qt programs using Qwt on Mac OS X?
I always get an error telling me that it can't find libqwt.dylib. For what I have understood from my googling it won't help to set DYLD_LIBRARY_PATH in environment.plist since Apple has disabled that due to security reasons so how am I supposed to do it (without manually copying the lib to my .app for every recompile)?
I have tried both qmake -spec macx-g++ and qmake without any spec. The lib is in /usr/local/qwt/lib at the moment. Should I move it to some system path manually or is there a better way to do it (by using otool and install_name_tool magics)?
I think it's bad idea to edit environment.plist or in any other way to change your profile settings to add such "non-standard" path to it.
I assumed you have something like this in you project *.pro file:
INCLUDEPATH += /usr/local/qwt-5.2.0/include
LIBS += -L/usr/local/qwt-5.2.0/lib \
-lqwt
Or you try to run one of samples where all this additional path are included by:
include( ../examples.pri )
Anyway you get this message at program start:
dyld: Library not loaded: libqwt.5.dylib
Referenced from: /Users/kemiisto/Downloads/qwt-5.2.0/examples/histogram/histogram.app/Contents/MacOS/histogram
Reason: image not found
The program has unexpectedly finished.
Well, you can use solution from this blog post. I have tested it with Qt 4.6 and Qwt 5.2. It works.
After running qmake -spec macx-g++ in qwt sources distribution directory (already done by you), edit src/Makefile. Find the string with
-install_name libqwt.5.dylib
and make it looks like this (change to full path)
-install_name /usr/local/qwt-5.2.0/lib/libqwt.dylib
Now (re)build Qwt (make clean && make) and reinstall it (sudo make install).
Related
I need to use libpng for my coursework with Qt. But I don't know how to install it and use with Qt on Windows.
Try to install with MinGw
Firstly, I've downloaded libpng and zlib from official site. Then I've tried to install it with MinGw, ./configure CFLAGS='-O2' CXXFLAGS='-O2' --prefix=/mingw this command executes perfectly, but then I got a problem. After typing make and make install I've got following issue. I don't know how to fix it and what it actually mean, because I've never faced errors from makefiles.
Try to install via application
I've found an application for installing libpng on windows: http://gnuwin32.sourceforge.net/packages/libpng.htm. And it worked, I've installed a library, got my lib files and headers. Then I went to my Qt project, and added a library, by pointing path to lib file and path to headers. Now I'm including png.h in my class and things seems to go well, until I try to use some functions. Qt writes something like this No mathcing function for call to png_sig_cmp. But more interestingly, that it actually don't show errors when I use variable types from library, for example png_byte.
//messege from MinGw after typing make and make install
rm -f pnglibconf.c pnglibconf.tf[45]
gawk -f ./scripts/options.awk out=pnglibconf.tf4 version=search\
./pngconf.h ./scripts/pnglibconf.dfa\
./pngusr.dfa 1>&2
gawk -f ./scripts/options.awk out=pnglibconf.tf5 pnglibconf.tf4 1>&2
options.awk: bad line (10): com
make: *** [pnglibconf.c] Error 1
I expect to install library on my disk and be able to include it in other projects in other IDE fast.
For your build problem Google search yields: https://github.com/aseprite/aseprite/issues/1054#issuecomment-335846694 .
Suppose you built not libpng, but libcurl as I did a while ago with mingw compiler,
then to use libcurl within your Qt project file do:
win32 {
## Windows common build here
win32-g++:contains(QMAKE_HOST.arch, x86_64):{
message("x86_64 build")
INCLUDEPATH += C:\QT64\Lib64\curl-7.40.0-devel-mingw64\include
LIBS += C:\Qt64\Lib64\curl-7.40.0-devel-mingw64\lib64\libcurldll.a
# Win64 specific build here
} else {
message("x86 build")
INCLUDEPATH += C:\QT\Lib\curl-7.40.0-devel-mingw32\include
LIBS += C:\Qt\Lib\curl-7.40.0-devel-mingw32\lib\libcurldll.a
#Win32 specific build here
}
}
I'm having trouble deploying .exe generated with QtCreator on Ubuntu 14.04. I got several versions of qwt installed (and i need those, one compiled with qt4 the other with qt5).
Problem is, i don't know why but Qt seems to link the wrong version of qwt to my .exe whatever i do .. When i use LDD on my .exe, it always show /usr/lib/libqwt.so.6. Thing is i'm linking the version i need in my .pro like this :
LIBS += -L/usr/local/qwt-6.1.2/lib/ -lqwt
And in project configuration i set LD_LIBRARY_PATH with /usr/local/qwt-6.1.2/lib
Still my .exe doesn't link to the right library.
Any idea why and how to fix this ? It causes segmentation fault on launch of course as my program is compiled with qt5 and not qt4..
Thanks in advance
You can try adding a runtime path to the linker flags. In your .pro file you can add the following line (Its probably worth printing your QMAKE_LFLAGS in your pro file as well):
QMAKE_LFLAGS += "-Wl,-rpath,/usr/local/qwt-6.1.2/lib/"
message ("QMAKE_LFLAGS = $$QMAKE_LFLAGS")
Re-compile and then run ldd again. During runtime also ldd) your program should now point to this location first.
Note
This is assuming that you are using a gnu compiler!
I sorted out my problem, seems like settings the environment variables in QtCreator is not enough. You have to do it in the terminal aswell before launching the .exe, that was my bad.
Just had to set LD_LIBRARY_PATH correctly.
I am pretty new to setting the Qt Creator environment in Linux.
I will cross compile this demo program to the Yocto Project i.MX6. This demo program needs to use Qt-GStreamer
in demo.pro
There is these 2 lines
CONFIG += link_pkgconfig
PKGCONFIG += Qt5GLib-2.0 Qt5GStreamer-1.0 Qt5GStreamerUi-1.0 Qt5GStreamerUtils-1.0 Qt5GStreamerQuick-1.0
at compile in the Desktop, it shows
error: Qt5GLib-2.0 development package not found
This applies to all the other packages as well.
I know that it tells me that I am missing the package for the Qt Gstreamer.
However, when I look at this thread, the answer is
export PKG_CONFIG_LIBDIR=/home/anisha/Desktop/newGSTr/qt-gstreamer-0.10.3/lib/x86_64-linux-gnu/pkgconfig
But, from what I have downloaded in Qt Binding-GStreamer qt-gstreamer-0.10.3 Does not have the lib folder inside.
I have also used cmake to work with the CMakeList.txt inside the folder but encounter Qt missing packages error.
Could someone help me on setting up those packages?
Is there any simple way to configure Qt Creator to compile qupzilla in my folder (not in /usr/bin and /usr/lib)?
By default i get "error: ../../bin/libQupZilla.so". If i set the path to my app folder with ldconfig - app is compiled but without plugins. They return errors for example (build/qrc_testplugin.cpp Error 1 or something with locale folder).
OS: Arch Linux 64 bit
QT: Qt5
Also i successfully compile qupzilla-git from AUR with qt5. This means that my problem somewhere in incorrect settings or paths...
Qupzilla: http://www.qupzilla.com/
Solution:
1) Add path to programm "path_to_app/bin" to ldconfig (/etc/ld.so.conf)
2) Check off in Projects "Shadow build" checkbox.
3) Change qmake to qmake-qt5. If I understand correctly, it is not necessary to do. Since in Arch Linux qmake and qmake-qt5 same.
4) In build environment add
KDE true
USE_WEBGL true
If you have libQupZilla (or any library) somewhere else than system library directories, easiest is to edit the .pro file, add line like:
LIBS += -L$(PWD)/..relative-path-to-library-location../
...or use absolute path to the library if you want. You probably already have -lQupZilla there, so no need to add that the 2nd time.
In general, with problems like this in Qt Creator, look at the Compile Output tab (at the bottom of the screen). Find the link command (note: if project uses cmake instead of qmake, you may need to add some switches or something for that to make the command visible), which is the one with all the -L/path and -lfoobar switches, and -o programname outputting the final target. Then look earlier to see in what directory it is being run in. Then look if everything matches, and possibly try to copy-paste and run the command from command line yourself, in the same directory where it is run when building under Qt Creator.
I've recently began learning the SFML API for learning purposes but it seems to me like it only supports Codeblocks IDE and Visual Studio. I dislike both IDEs for my own ideas and I like the IDE that comes with Qt instead.
Is it possible to basically use SFML within the Qt creator?
EDIT:
I know some of you may some day find this on google, after struggling for 8 days to set up sfml to work with qt creator I've found the sollution:
step 1: Download the VS version of SFML from the website (NOT codeblocks version)
step 2: copy the DLLs from C:\SFML-1.6\lib to your system32 directory
step 3: open qt creator, make a plain C++ project, open your .pro file and add these lines:
INCLUDEPATH += C:\SFML-1.6\include
LIBS += C:\SFML-1.6\lib\sfml-system.lib \
C:\SFML-1.6\lib\sfml-window.lib \
C:\SFML-1.6\lib\sfml-graphics.lib \
C:\SFML-1.6\lib\sfml-audio.lib \
C:\SFML-1.6\lib\sfml-network.lib
And you're done!
Short answer: Yes.
The IDE doesn't really matter all that much. The compiler does. Depending on the compiler used by Qt Creator, you download the appropriate SFML package. Most likely the MinGW based version will work just fine with your default install of Qt Creator. (I believe that relies on MinGW?)
All that then remains to be done is place SFML in its own directory and making sure that you set up the correct paths in your Qt Creator project. There's not much to it really.
I know i'm a little bit late to the party but:
SFML library is 100% compatible with qtcreator especially qmake.
Download SFML from https://www.sfml-dev.org/download/sfml/2.5.1/ . Bottom right minGW (You most likely have mingw on qt)
Place it somewhere you will know where it is. I usually put it in "C:/SFML-2.5.1"
There's a simple copy pasta you can add to your qmake '.pro' file:
INCLUDEPATH += "C:/SFML-2.5.1/include"
LIBS += -L"C:/SFML-2.5.1/lib"
CONFIG(debug, debug|release){
LIBS += -lsfml-audio-d -lsfml-graphics-d -lsfml-network-d -lsfml-system-d -lsfml-window-d
} else {
LIBS += -lsfml-audio -lsfml-graphics -lsfml-network -lsfml-system -lsfml-window
}
The 'INCLUDEPATH' includes the headers into your project where as the 'LIBS' adds the library file path. The 'CONFIG()' tells qt if you're running DEBUG mode or RELEASE mode.
This copy pasta is fun because you can also configure a custom wizard and make qt dropdown show you a 'create new sfml c++' project by just editing its profile with this.
Last but not least are the needed .dll files from 'C:\SFML-2.5.1\bin' You can add only the ones you need or all of them if you're lazy. You can do this by copying them into the BUILD folder of your project. (to find the build folder by default its a folder in the same path as your project folder with the name of your project prefixed by 'build-' or 'release-')
Make simple c++ project
Choose QMake build system
in project.pro add 2 lines:
CONFIG += link_pkgconfig
PKGCONFIG += sfml-all