How configure Qt Creator to compile qupzilla? - c++

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.

Related

How to run qmake from the static Qt

For making a very simple Qt app "installable" on other systems, I'm using Qt Installer Framework following this link.
In bottom, in Setting up Qt Installer Framework, number 1 orders to have Qt Installer Framework source code. I downloaded it from here. (qt-installer-framework-opensource-2.0.1-src.zip)
Now I don't understand the next instruction there :(
It says:
2- Build the tools by running the "qmake" from the static Qt, followed by "make" or "nmake".
My question is, first what does it mean?
And from what path?
I don't know how to do it:(
qmake comes with the qt-framework and is a make file generator. (an alternative to cmake).
You call qmake on a .pro file from your project. This .pro file have to contain your source code files project dependencies and more.
Consider that you have a project folder with your source code and the .pro file. Then you call the qmake command in this folder. qmake is an program itself, which you can find in the bin folder of your qt-installation. If qmake is in your path variable, you go to the terminal, navigate to the specific folder and just write:
qmake
After that qmake will create a makefile. Then you could call makeand your program will be build.
I hope my answer helps you. You can learn more about qmake on the website of Qt. Here is also a very good qmake tutorial: klick
edit:
how to call make on windows:
download and install cygwin from
http://www.cygwin.com/setup-x86.exe - 32 bit installer or
http://www.cygwin.com/setup-x86_64.exe - 64 bit installer.
then start the Cygwin terminal (Cygwin.bat) and navigate to your folder and call
make
and that will build your qt-installer!

Qwt version conflict QTCREATOR

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.

QtCreator - Can't link against static library (ld error)

I'm having a problem while using QtCreator 3.0.1 with Qt 5.2.1 on Linux. I'm trying to compile my project using QtCreator's built in 'build' function, which I imagine runs qmake project.pro and then make. My project uses QScintilla, which I have compiled into a static library (.a), and included in my project's directory in qscintilla/Qt4Qt5.
After compilation is done, the compile output pane shows the following:
/usr/bin/ld: cannot find -lqscintilla2
collect2: error: ld returned 1 exit status
My .pro file contains:
LIBS += -Lqscintilla/Qt4Qt5 -lqscintilla2
However, running qmake and then make on the project's root directory via a terminal emulator works perfectly, and the project is compiled and linked successfully. I have double checked that the qscintilla/Qt4Qt5 directory contains the file libqscintilla2.a.
Since you seem to be using Linux, it would be better to leave the package with your distribution. Getting packages installed bringing static libraries into the system would be more "vanilla".
However, if you wish to stick to the in-project build principle, I would suggest not to disable the shadow build and create other workarounds having their own limitations.
You could for instance use the $$OUT_PWD variable for this purpose, but in general, you would need to specify the target dependency as well between the components.
So, you would be writing something like this then:
LIBS += -L$$OUT_PWD/qscintilla/Qt4Qt5 -lqscintilla2
Please adjust this based on your directory layout.
You should also add the line:
PRE_TARGETDEPS += qscintilla/Qt4Qt5/libqscintilla2.a
to your .pro file in order to link the library statically.
Managed to make it work: on QtCreator, click on "Projects" on the left pane, which will open a tab which allows you to edit the build/run/style options. On the Build/General section, disable "Shadow build". This will build the project on the original project directory.
Edit: see #LaszloPapp's answer for a better solution.

Qt unit-test: why "qmake" is not recognized

I managed to follow this tutorial in order to write my first unit-test.
However, when opening a "cmd-console" from inside my project folder and try to rum qmake, i get the following error:
'qmake' is not recognized as an internal or external command, operable program or batch file.
so, why qmake is not recognized? (note that I am working on windows Vita)
On Windows qt and its tools are installed by default in C:\Qt\blablah. You should add the path to the qmake binary, and that will do the trick. See the instructions here. Note that Qt creator set some variables for its terminal so you use qmake in creator without touching the system.
set path the Qt compiler.
sth like this:
set PATH=C:\Qt\4.8.5\bin
where the 4.8.5 is the version of Qt you installed.
If you don't want to add the QT bin path to PATH you can write the full path to qmake:
>"$(QTDIR)\bin\qmake.exe" -o Makefile odbc.pro
where $(QTDIR) is the full path of the qtbase directory.

Qt app finds libraries when launched from QtCreator, but not from command line

I need to ship a product with shared libraries (Ubuntu) in a folder I've created ('shared') within the project directory--i.e., shared libraries that are not in /usr/lib, /usr/local/lib, etc. To this end I've done this in the .pro file, i.e.
LIBS += -Lshared/gsl -lgsl -lgsl_cblas
NB the executable is in the same directory asy the 'shared' folder. Everything works when I launch the program in debug mode from QtCreator. In addition the program fails to launch if I remove or rename the libs in 'shared', and also I've verified that the app is not finding these libraries anywhere else. But when I launch from the command line, I get
error while loading shared libraries: libgslcblas.so.0: cannot open
shared object file: No such file or directory
What's going on?
EDIT: The solution is a variation on lionbest's below, as developed in the comments. For some reason, it turns out that on my platform qmake/QMAKE_FLAGS only allows a specific format for linker options, and not the one you find googling around for other instances where people have worked with QMAKE_FLAGS. Namely,
QMAKE_FLAGS += "-Wl,-rpath,\'\$$ORIGIN/shared/gsl\'"
QMAKE_LFLAGS_RPATH=
Specifically, the problem was that the parser (or linker) would not accept -rpath=..., despite the fact that this seems to work for everyone else. Ubuntu 12.04, gcc 4.6.3, Qt 4.8.0, QtCreator 2.4.1 "based on Qt 4.7.4". Hope this experience can save someone else the same frustration.
Start a program with environmental variable LD_LIBRARY_PATH=shared/gsl or add a RPATH to linker settings:
LIBS += -Wl,-rpath=shared/gsl
If you want to make shortcut for your application, most distribution (based on Gnome, KDE, LXDE and XFCE) use a .desktop file. QtCreator probably generated one for you. You need to edit it or generate it, and put to $HOME/.local/applications or /usr/share/applications/ during installation. In desktop file you could add envirometal varible and starting directory as follow:
Exec=/usr/bin/env LD_LIBRARY_PATH=/<path_to_libs>/ /<path>/app -extra_options
If you need to run your application in specific directory add line:
Path=/<path_to_your_application_working_dir>
You can use ${} inside path.