Developing Qt applications in Unix systems using Qt Creator - qt

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.

Related

Cannot find c:\Users\qt\work\install\lib\Qt5Widgetsd.lib when compiling QtWebEngine examples

I downloaded Qt5.6 VS2013 32bit and try to run the official example of QtWebEngine.
I just followed the instruction but
When linking it gives out an error of
LNK1104 file not found c:\Users\qt\work\install\lib\Qt5Widgetsd.lib.
However, I have no idea of where this path c:\Users\qt\work\install\lib\ comes from.
I did text search in all directories of example folder and no hits other than generated files(makefiles and pdbs).
I also checked system environment variables but no hits.
Furthermore, I checked Qt Creator'r Projects panel and its Build Environment and still no hits.
Did I miss something?
P.S. this error was given out by linking DemoBrowser example of QtWebEngineWidgets pro
The link is generated by qmake when it generates the build scrip from the qt project file (*.pro). It is based from the qmake application path that is generaly installed together with the libraries (check you qt kit setup to change it if needed: Jst browse to qmake.exe application).
Then try regenerate the build script. It should fix the issue.
You may also have issue with installation not being in debug mode; you are trying to use Qt5Widgetsd.lib library instead of the non-debug one Qt5Widgets.lib

Error in OpenCV configuration for Qt Creator

I followed these instructions in the configuration of OpenCV SDK for using it in Qt Creator IDE, but I couldn't conclude point 6.5, due to configuration errors in Cmake-GUI. I setup the configuration in CMake of the compilers gcc and g++ contained in Qt folder for MinGW32, and all looks Ok. But when Cmake-GUI starts the process of build configuration it ends up saying
"Error in configuration process, project files may be invalid".
It can't find the following:
QT_QMAKE_EXECUTABLE;
Qt5Concurrent_DIR;
QT5Core_DIR;
QT5Gui_DIR;
QT5Test_DIR;
QT5Widgets_DIR.
After this issue I tried to go on with following points of configuration tutorial, without reaching the final instruction of mingw32-make install. I'm using the following versions of softwares: Qt 5.3.0, OpenCV 2.4.9, CMake 2.8.12.2. My OS is Windows 7.
How can I recover the missing Qt files in CMake configuration?
Is there an alternative way for configuring OpenCV with Qt (like using precompiled build of OpenCV libraries)?
You just need to indicate CMake the correct paths to each one. Click oh the path to browse and set each one individually:
QT_QMAKE_EXECUTABLE;
For this one, you need to search inside the Qt installation folder for the /bin directory. On it, you' ll find the qmake.exe. In my case it was C:/Qt/5.3/winrt_x64/bin/qmake.exe
All the following ones are in the Qt's /lib/cmake directory. In my case: C:/Qt/5.3/winrt_x64/lib/cmake :
Qt5Concurrent_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Concurrent
QT5Core_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Core
QT5Gui_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Gui
QT5Test_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Test
QT5Widgets_DIR.
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Widgets
Then click generate. It' ll show a new error and ask you for the QT5OpenGL_DIR. Just as before, show CMake the correct directory. In my case: C:/Qt/5.3/winrt_x64/lib/cmake/Qt5OpenGL. Finally, click Configure again, and then Generate, and now you're done creating the build files.
You have to specify the location of Qt manually by passing it as an argument for QT5Core_DIR. Qt5_DIR or CMAKE_PREFIX_PATH does also the trick.
Example
Given your Qt 5 is installed at /opt/selfcompiled/Qt5. When calling cmake, add the flag from above:
cmake -DQt5_DIR=/opt/selfcompiled/Qt5 <pathToSourceDir>
Once the Qt 5 directory is set and found by CMake, all the other variables related to Qt 5 should be found from there, too.

Compiling Qt project in a directory outside of the install directory

I've been working on a project using OpenCV for a while, and am ready to upgrade my user interface from using cvWaitKey() to get key presses and emulating buttons with trackbars. Ha. So I've decided to use Qt.
I'd like to continue developing in the same directory I've been using, which is, of course, outside of the Qt install directory, C:\Qt\2010.05\qt. Using the "Qt Command Prompt", I'm able to compile the Hello Notepad example in directories both in and out of C:\Qt\2010.05\qt, namely C:\Qt\2010.05\qt\abc and C:\Qt\2010.05\abc.
However, while compiling under C:\ ... \qt produces executables in both the debug and release directories, compiling outside of it only produces the debug executable, along with a .o file (object code?). I did some comparisons using WinMerge, and found that the following lines (among others) differ in the two makefiles (generated using qmake -project and then qmake):
Inside qt\
first: all
install: debug-install release-install
uninstall: debug-uninstall release-uninstall
Outside qt\
first: debug
install: debug-install
uninstall: debug-uninstall
That's clearly the problem (the .pro files generated by qmake -project differ only in timestamp). I'm sure there's an easy answer out there to what's causing this... I hope there's an easy answer to how I can work around it. Also, I intend to use QtCreator some; hopefully the solution is the same for the IDE as the Command-Line compiler.
Thanks!
Nolan
p.s.: I don't think this is the same issue: Qmake does not support build directories below the source directory ...in any case, I'm not sure I understand the answer.
You should be able to add
CONFIG += release
to your .pro file, to build for release target. There's also
CONFIG += debug_and_release
iirc.
QtCreator has a GUI element for toggling between build targets, you might try opening the .pro with that application if you find you need to switch back and forth often.

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

Hardcoded QMAKESPEC in Qt Creator?

I installed Qt SDK (Qt framework + Qt Creator) but didn't like the layout of folders so I deleted it (without uninstalling), moved framework in one place and Qt Creator in another and installed Qt framework and Qt Creator separately placing each over the respective old one.
The problem is Qt Creator in Projects/Build Settings/Build Steps keeps showing the old path to the specification file:
-spec c:/qt/2009.03/qt/mkspecs/win32-g++
Setting QMAKESPEC environment variable either in the system or in Projects/Build Environment doesn't change anything.
How can I force Qt Creator to see and use new location of the specification file?
This does not fully solve the issue but if you add '-spec' (without quotes) in the additional arguments box in build steps -> qmake, then it removes the win32-g++ argument.
NOTE: I have NOT been able to build the project after doing this (i changed it to win32-icc and win32-msvc2008 as i have both the intel c++ compiler and VS2008) but the build fails with the error ---- "*** MIssing Separator. Stop." in the makefile
I don't have Qt Creator installed, but I suppose it may store this setting somewhere on filesystem, look in your %HOME% or %APPDATA% for directories associated with Qt Creator and search the files inside for this path.
Have you tried going into Projects->Build Settings->General and clicking on the "Manage Qt Versions" and making sure that everything there is all correct?

Resources