collect2:error in Qt - c++

I just installed Qt and I created a console project and printed hello world and it printed that out perfectly. I also added opencv libraries to the same project and was able to load an image successfully. Then i created a new project as qt widget application project and without making any changes to the project (which comes with the main window class and main source file) I run it the following error pops up.
error: cannot find -lGL
error: collect2: error: ld returned 1 exit status
what do I do?
my .pro file
#-------------------------------------------------
#
# Project created by QtCreator 2015-03-15T17:46:46
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui

I was able to fix this. Apparently it depends upon the libgl1-mesa-dev package. So install the package and restart Qt . I have ubuntu 14.04.02 and it showed some errors when I tried installing in the conventional way
sudo apt-get install libgl1-mesa-dev
So I tried
sudo aptitude install libgl1-mesa-dev
That didn't work well either. A different website showed a way around it
sudo apt-get install xserver-xorg-dev-lts-utopic mesa-common-dev-lts-utopic libxatracker-dev-lts-utopic libopenvg1-mesa-dev-lts-utopic libgles2-mesa-dev-lts-utopic libgles1-mesa-dev-lts-utopic libgl1-mesa-dev-lts-utopic libgbm-dev-lts-utopic libegl1-mesa-dev-lts-utopic
This installed properly. Now when I restarted Qt it worked properly.
for your reference:
http://xrong.org/notes/install-Qt-OpenCV-Ubuntu
http://answers.ros.org/question/203610/ubuntu-14042-unmet-dependencies/

Related

Error deploying Qt application on OS X

I'm trying to deploy a Qt application on OS X using macdeployqt:
macdeployqt MyApplication.app -dmg
The application uses the Qwt library, which is being included in the PRO file as follows:
macx: QWT_ROOT = /usr/local/qwt-6.1.0
include ( $${QWT_ROOT}/features/qwt.prf )
When I run the macdeployqt command I get the following error message:
ERROR: no file at "/Library/Frameworks/qwt.framework/Versions/6/qwt.framework/Versions/6/qwt"
I'm not sure but it seems the deployment step is looking for the Qwt library on the wrong path, for example:
"/Library/Frameworks/qwt.framework/Versions/6/qwt.framework/Versions/6/qwt"
When it should be:
"/Library/Frameworks/qwt.framework/Versions/6/qwt"
How can I solve it?
I have uninstalled other qt versions using brew list, brew remove qt and brew remove qt5. I also noted that I had pyqt installed (and I was not using it), so I also remove it using brew remove pyqt.
Then, I have reinstalled Qt 5.3.2 and had other issues:
Project ERROR: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild.
Which was solved changing the isEmpty($$list($$system("/usr/bin/xcrun -find xcrun 2>/dev/null"))) command from the Qt_install_folder/5.7/clang_64/mkspecs/features/mac/default_pre.prf file to isEmpty($$list($$system("/usr/bin/xcrun -find xcodebuild 2>/dev/null"))), as explained here: Qt Creator - Project ERROR: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild
and
Could not resolve SDK path for 'macosx10.8'
That was solved by changing the QtPath/5.3/clang_64/mkspecs/qdevice.pri from !host_build:QMAKE_MAC_SDK = macosx10.8 to !host_build:QMAKE_MAC_SDK = macosx10.12, as explained here: Error: Could not resolve SDK path for 'macosx10.8'
So, I run the command from my Qt directory:
/Users/kuser/Qt5.3.2/5.3/clang_64/bin/macdeployqt MyApplication.app -dmg
and it worked.
I found these solutions in comments from the following question:
Qt5 cannot find platform plugins Mac OS X
Note: this does not solve the macdeployqt error directly, but as it is part of the Qt installation, reinstalling it solved my problem.

QT: QTWebview is not working

My operating System: Windows 7 64bit
QT Version: QT Creator 4.2.0 based on QT 5.7.1(MSVC 2015, 32 bit)
The QWebview widget is not displayed in my mainwindow.ui file.
I already tried following steps:
-QT += webkitwidgets or QT+= webenginewidgets
-include <QTWebView> or include <QTWebEngineView>
After using the above commands i got this project error:
Project ERROR: Unknown module(s) in QT: webenginewidgets
I also tried to reinstall the QT Creator, but i still got the same problem, i cant use any web-related widgets(Webkit/WebEngineView, ...).
Thanks for your help.
Best regards.

QT File menu not integrating into title bar

I am writing a basic gui application in QT creator 3.5.1 and I am using QT 5.5. I have downloaded QT/QT creator via their website. I am currently running Ubuntu 15.04 64 bit.
I am running into an issue regarding the integration of the menu bar into the title bar. The issue being that no integration is happening (the menu bar isn't appearing in the title bar) . The menu bar appears where it would have in the past, below the tile bar. Here is an image of what is happening:
How can I go about resolving this issue?
UPDATE:
I installed qt 5.4.1 via apt-get, and qt creator. When I compile against this, my title bar integration works! So the question is, what is different? The people I am developing with are using QT 5.5.1, and I would like to use the same version as them. Is there something I can do differently this time around?
The unique way that i found was in this blog. He claims that this method works on Qt Creator, but i've tested on Ubuntu 32/64 bits Qt5 apps (developed by me) and it seems to works fine too!
The steps are:
Open terminal
Enter sudo apt-get install libgtk2.0-dev libdbusmenu-qt5-dev
Set current directory with CD command (the appmenu project will live here)
Enter command apt-get source appmenu-qt5
Now, the blog still using command line but the next steps can be done by opening the project in Qt Creator (the project is on the current directory).
Using some text editor (can be Qt Creator of course), edit the following lines of appmenu/src/src.pro:
CONFIG += X11 link_pkgconfig debug
PKGCONFIG += dbusmenu-qt5 gtk+-2.0
DESTDIR = ./
to (if you want a dynamic library):
CONFIG += X11 link_pkgconfig
PKGCONFIG += dbusmenu-qt5 gtk+-2.0
or (if you want a statically linked library):
CONFIG += X11 link_pkgconfig static
PKGCONFIG += dbusmenu-qt5 gtk+-2.0
Open the project with Qt Creator (if you haven't done already) select the mode of build (Release mode seems to be smaller in size) and build.
If built succesfully (as a dynamic library), you will have inside your Qt5 installation folder /plugins/platformthemes a plugin called libappmenu-qt5.so. To get menu integration, just place the lib in a platformthemes subfolder of your target app (including Qt Creator).
Or if built succesfully (as a statically linked library), you will have inside your Qt5 installation folder /plugins/platformthemes a file libappmenu-qt5.a. This is the static library. To integrate it with your app, add to your project file:
QT += core-private gui-private platformsupport-private dbus widgets
LIBS += $$[QT_INSTALL_DATA]/plugins/platformthemes/libappmenu-qt5.a
CONFIG += X11 link_pkgconfig
PKGCONFIG += dbusmenu-qt5 gtk+-2.0
And to your main.cpp:
#include <QtPlugin>
Q_IMPORT_PLUGIN(AppMenuPlatformThemePlugin)
int main(int argc, char *argv[])
...
And this should be the result:
Edit (valid when building as dynamic library): Note that you wouldn't need to recompile your Qt apps nor Qt Creator .
For Qt Creator you need to place libappmenu-qt5.so in your Qt Installation folder: /Tools/QtCreator/lib/Qt/plugins/platformthemes
If you want to redistribute your Qt application, just share inside the folder of your executable the folder platformthemes with libappmenu-qt5.so inside it. Like any other Qt plugin.
Edit 2: Is also possible to build a statically linked plugin, if you don't want extra dependencies.
You can try to set "nativeMenuBar" property of QMenuBar Object is false.
Because this property has the default value is true.

openCV in Qt Creator on Mac

I am new to C++ so this is probably a simple fix, but I have not been able to run my program even after reading Stack Overflow's many posts regarding openCV and Qt creator. This is now my 4th day trying to get openCV working in Qt creator, so any help would be greatly appreciated!
I know openCV is installed and working on my computer because I am able to build and run programs using it by running g++ pkg-config --libs --cflags opencv -o name name.cpp in terminal, just as long as I don't try to use openCV in Qt creator. I installed openCV through Homebrew and downloaded Qt creator from its website. I also have qt installed by running "brew install qt" in terminal.
I tried linking openCV to my Qt project by editing the project file which now reads:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = opencvTestQT2
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
QT_CONFIG -= no-pkg-config
CONFIG += link_pkgconfig
PKGCONFIG += opencv
But upon trying to run it I get the error:
opencv development package not found
I have also tried adding to my project file lines such as:
INCLUDEPATH += /usr/local/Cellar/opencv/2.4.11_1/include/
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.10
LIBS += -L/usr/local/Cellar/opencv/2.4.11_1/lib -lopencv_imgcodecs -lopencv_highgui
but none of them allow my program to be built.
I am using a Mac running version 10.10.4, openCV 2.4, and Qt Creator 3.4.2 in case that helps.
Thanks in advance
Click on projects on the left pane -> Build & Run -> on Build Environment, add Path to /usr/local/bin in order for qt creator to find the pkg-config.
as Dae Choi said, the pkg-config is not found. Doing that procedure will work. Just remember to update the run as well.
This error will show:
Starting /Users/sgb/build-imagenes-Desktop_Qt_5_9_1_clang_64bit-
Debug/NBasic.app/Contents/MacOS/NBasic...
dyld: Symbol not found: __cg_jpeg_resync_to_restart
Referenced from:
/System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /usr/local/lib/libJPEG.dylib
in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
The program has unexpectedly finished.
Just update in Projects -> Build & Run -> Run -> DYLD_LIBRARY_PATH to unset. Save and compile again. There are other thread where you can check as well.
Qt application throws “dyld: Symbol not found: __cg_jpeg_resync_to_restart”

Unknown module(s) in QT: multimedia

I have downloaded qt-everywhere-opensource-src-5.4.1 and build and installed static.
Next i built QMultimedia and installed.
I get "Unknown module(s) in QT: multimedia" from the .pro when including
QT += multimedia.
I have QtMultimedia,QtMultimediaQuick_p and QtMultimediaWidgets in /usr/local/Qt-5.4.1/include.
Also have mediaservice,playlistformats in /usr/local/Qt-5.4.1/plugins
Also have QtMobility,QtMultimediaKit in /usr/include
I am running Ubuntu 15.0
All related issues i've found did not help.
Please run:
sudo apt-get install qtmultimedia5-dev
afterwards you can install other multimedia packages as needed, but this enables the multimedia in general.