Libqxt under Qt Creator - qt

I want to create a tiny app which needs global shortcuts. So, I have downloaded the current version of libqxt (0.5.1) and opened as a project in Qt Creator.
Libqxt compiles without problems in this way, so I thought that adding this in the tab Dependencies of my project it would get added automatically in the build, like Eclipse does with JAR libraries (I know that are different IDEs but it seems to be a common feature among them).
What happens? Qt Creator compiles qxt before my project, when needed, but when I want to include its headers Qt Creator keeps warning me that it cannot find them.
Probably I am missing the correct name of headers (I tried the headers showed in qxt documentation: http://doc.libqxt.org/0.5.0/classQxtGlobalShortcut.html)
By the way, I looked the code for global shortcuts and I think I can rip it out and use it in my app as is and I am going to credit qxt team and open the code of my app.

from the documentation
Add the following lines to your .pro file:
CONFIG += qxt
QXT += core gui
Note: While building the Qxt on Linux do not forget to do a sudo make install otherwise this little piece of magic may fail to work.

Qt Creator doesn't know how to expose different libraries to your projects. It's developer's duty. Dependency ensures only that mentioned projects are already built before building your main project.
Your real concern was using Qxt without proper installation. Assuming that configure have been run and libqxt have been built (using Qt Creator or manually via qmake+make), my solution is adding following snippet (with obvious QXT_DIR customization) to .pro file:
QXT_DIR = $${IN_PWD}/../libqxt-0.5.1
LIBS += -L$${QXT_DIR}/deploy/libs
INCLUDEPATH += $${QXT_DIR}/deploy/include
for(module, QXT) {
MODNAME = $$upper($$replace(module, "(.).*", "\1"))$$replace(module, "^.", "")
INCLUDEPATH += $${QXT_DIR}/deploy/include/Qxt$${MODNAME}
INCLUDEPATH += $${QXT_DIR}/src/$${module}
win32:CONFIG(debug, debug|release):MODNAME = $$join(MODNAME,,,d)
LIBS += -lQxt$${MODNAME}
}
Unfortunately I'm not sure whether it works in complex projects.
By default Qxt is built in release mode, but Qt Creator uses debug mode and it leads to broken binaries of projects depending on Qxt under Windows. You have to switch your project to release mode or build Qxt in debug mode (run configure -debug and rebuild Qxt).
Last thing: In Windows you won't be able to run your project from Qt Creator even if you successfully build it. You must copy needed Qwt*.dll files (use the d-suffix versions if you're in debug mode) from libqxt-0.5.1/deploy/libs to your_project/(release|debug) directory .

Related

QtCreator (2.8.0), using shared libraries

I developing a GUI app with Qt 5.1 and QtCreator 2.8.0 and I'm using a shared library (also compiled with Qt 5.1).
This is what I'm using in the .pro file:
INCLUDEPATH += ../MyLib
QMAKE_LIBDIR += ../MyLib/build/release
LIBS += -lMyLib
Regarding the "Run Configuration" (QtCreator) and under Linux (Ubuntu 12.04) I set the LD_LIBRARY_PATH to "(...)/MyLib/build/release" and it works well. However, on Windows, appending the library path (.dll) to PATH doesn't work. I don't get any compiling nor linking errors but when I run the app it immediately exits. If I put the .dll on the same folder as the executable it runs without any problem. Am I missing something?
Hard to say from the information you gave. Surely Windows does find the dll if you put its path into PATH. But maybe your dll uses another dll, which is not in the normal search path?
You might want to try the dependency walker: http://www.dependencywalker.com/
If your dll is based on Qt it might be that it does not find necessary qt plugins.
Check this out: http://qt-project.org/doc/qt-4.8/deployment-windows.html#application-dependencies
Qt 4, but Qt 5 is the same in this regard.

Configuring Qt creator for KDE applications

I want to build some KDE applications. Here's what I did so far:
sudo apt-get install kde-full
add LIBS += -lkdeui in the .pro file of a project which used KDE libraries.
I am using the QtCreator and the above mentioned steps don't seem to be enough. Error message: KApplication: no such file or directory.
What are the steps to configure my system for KDE application development?
The recommended way to build a KDE project is use CMake, not QMake. I really recommend you this approach because some KDE applications, like plasmoids, can not be build correctly using QMake.
In addition you can use KDevelop, but if you prefer Qt Creator, you can use it with a CMake project without problems.
http://techbase.kde.org/Development/Tutorials/CMake
KApplication.h is typically located in /usr/include/KDE folder. Make sure you have it in your include path (i.e. INCLUDEPATH += /usr/include/KDE).

QtCreator: static library but still asking for DLL

I'm using QtCreator and I got two projects, each with an own PRO file.
The Viewer is a normal Qt app.
The other one, let's call it Utilities, is supposed to be a static library which is used in the Viewer.
However when I compile and run the Viewer (everything compiles fine), I get an error message telling me Utilities.dll was not found.
This is the first part of the PRO-file for Utilities:
QT -= core gui
TARGET = Utilities
TEMPLATE = lib
CONFIG += staticlib warn_on $$(QMAKESPEC)
Shouldn't it work that way?
Why is it compiling the Utilities.a file fine but asking me for the DLL at runtime? It's supposed to be a static library :(
Since I did not specify some needed libraries in Utilities.pro, it apparently did not link as you'd expect for a static library.
My platform is W7-x64, latest Qt SDK and MingW 4.4 bundled with it.
Hope anyone can help :/
Thanks!
The CONFIG += staticlib request your target library to be a static lib not the entire dependency chain ... I am pretty sure your .a lib will require mingw dlls to run ...
If you want to reduce dependencies try the MSVC tool chain (Qt provide pre-compiled package for that) you will end with one or two mandatory dll dependencies. Or you can link again static mingw SDK (you will probably have to build it your-self ...).

Developing Qt applications in Unix systems using Qt Creator

I'm developing a Qt application in Linux using Qt Creator (2.1 RC). I've created 2 projects, and used the wizard to add the library project to the application project. However when I run it, I receive the error:
/home/jakepetroules/silverlock/silverlock-build-desktop/desktop/silverlock: error while loading shared libraries: libsilverlocklib.so.1: cannot open shared object file: No such file or directory
Is there some qmake variable I can set so that Qt Creator will set up the environment properly to run? It's quite annoying to have to copy all the files to another directory with a launcher script just to be able to test the build. On Windows it works perfectly - Qt Creator automatically adds the directories containing the DLLs to the PATH when it runs your application (where running it from Explorer would say DLL not found). Mac OS X is even worse, having to run install_name_tool on everything...
So how can I set up my qmake files so everything works right from the run button in Qt Creator? Kind of hard to debug without this ability, too.
I've had a similar problem running qt apps with QTCreator on my linux machine. I've solved it by adding following lines to the .pro file of the client application:
unix:LIBS += -L/home/projects/my_libs/ -lmy_lib
unix:{
QMAKE_LFLAGS += -Wl,--rpath=/home/projects/my_libs/
QMAKE_LFLAGS_RPATH=
}
info on rpath is here: rpath
hope this helps, regards
Yes, Creator has a section where you can set whatever environment you need for running your app.
On Creator 2.0.0 this is accessed by: Projects -> Targets -> (your target) -> Run -> Run Environment (after you have opened your project)
You can then add or remove any environment variables you'd like, including LD_LIBRARY_PATH One thing I'm not sure of is if it is possible to substitute e.g. the build path into the value of those variables, so that you don't have to hardcode that into your LD_LIBRARY_PATH.
Another option would be to add a small shell script to your source tree which sets whatever variables are necessary, and add a "Custom executable" run configuration to run that script. That's accessed through the same screen.
Just using this:
unix:LIBS += -L/home/projects/my_libs/ -lmy_lib
unix:{
QMAKE_LFLAGS += -Wl,--rpath=/home/projects/my_libs/
}
It's sloved my problem too.

using external libraries in Qt/Symbian

To get Facebook integration in our Nokia Symbian application we intend to use this library:
http://gitorious.org/qfacebookconnect
It is not otherwise working completely correctly, but it's a good start.
I have my project (.pro and .cpp files, using Qt Creator), which works fine in the emulator. I included this libqfacebook in the project in this way (in the .pro file):
LIBS += -LC:\projects\Pristop\Nokia\facebook_lib\libqfacebook-build-simulator\debug -lqfacebookconnect
INCLUDEPATH += C:\projects\Pristop\Nokia\facebook_lib\qfacebookconnect\inc
It works fine in the emulator. I use Qt Creator for everything, also to build libqfacebook. But if I want to test the application on a real phone, so to prepare a .sis file, I get this error:
:: error: No rule to make target `\NokiaQtSDK\Symbian\SDK\epoc32\release\armv5\LIB\qfacebookconnect.dso', needed by `\NokiaQtSDK\Symbian\SDK\epoc32\release\gcce\udeb\DogajaItak.exe'. Stop.
So I need to get a .dso file based on the source code of the qfacebookconnect library. For the emulator .lib and .pdb were enough. Obviously the difference is that .dso is arm while .lib & .pdb are x86.
If I try to configure qfacebookconnect to build for the phone, I get this error:
Makefile:232: error: PKG file does not exist, 'sis' and 'installer_sis' target are only supported for executables or projects with DEPLOYMENT statement. Stop.
It is correct that I do not want a .sis, all I want is a .dso.
If I go to Projects->Build Settings for Symbian Device for qfacebookconnect and I remove the build step "create SIS package" for qfacebookconnect, there is no error anymore, but I still don't believe it built a .dso for me.
So the question is how to configure Qt Creator or the .pro file to build me a .dso, or how to include external libraries in my .sis in another way?
I needed to freeze the library..
I found all the information there:
https://code.google.com/p/qfacebookconnect/issues/detail?id=13

Resources