Cannot Parse Libraries In Linux Using Qt Enviornment - qt

After some helpful tips this is the new version of this post, the thing is that it seems my programs is somehow running but it just issues some errors...i don't know what is it actually mentioning, because the libraries are installed, i changed the path form LIBS += -LC:/usr/local/lib/ \ to LIBS += -L/usr/local/lib/ \ as some one said it's actually refering to windows while u r using linux(chakra) and then added "\" at the end of directories and added pkg-config to my .pro file , so this is the new version of a new problem... :
Starting /home/lucifer/PR0J3CTs/FirstOpenCV-build-desktop-Qt_4_8_2_in_PATH__System__Release/FirstOpenCV...
/home/lucifer/PR0J3CTs/FirstOpenCV-build-desktop-Qt_4_8_2_in_PATH__System__Release/FirstOpenCV exited with code 0
Debugging starts
the debug information found in "/usr/lib/libQtOpenGL.so.4.8.2.debug" does not match "/usr/lib/libQtOpenGL.so.4" (CRC mismatch).
the debug information found in "/usr/lib/libQtGui.so.4.8.2.debug" does not match "/usr/lib/libQtGui.so.4" (CRC mismatch).
the debug information found in "/usr/lib/libQtCore.so.4.8.2.debug" does not match "/usr/lib/libQtCore.so.4" (CRC mismatch).
the debug information found in "/usr/lib/libQtTest.so.4.8.2.debug" does not match "/usr/lib/libQtTest.so.4" (CRC mismatch).
the debug information found in "/usr/lib/libQtNetwork.so.4.8.2.debug" does not match "/usr/lib/libQtNetwork.so.4" (CRC mismatch).
the debug information found in "/usr/lib/libQtXml.so.4.8.2.debug" does not match "/usr/lib/libQtXml.so.4" (CRC mismatch).
the debug information found in "/usr/lib/libQtSvg.so.4.8.2.debug" does not match "/usr/lib/libQtSvg.so.4" (CRC mismatch).
the debug information found in "/usr/lib/libQtDBus.so.4.8.2.debug" does not match "/usr/lib/libQtDBus.so.4" (CRC mismatch).
Debugging has finished
this is my .pro Configurations [ As U can see I've commented (#) one of two LIBS configs, I just wanted to ask which could be more accurate or more helpful, yesterday i tried and it issued some incompatibility with newer version of libavcodec so I googled some and downloaded libavcodec.53 and configured it but I'm uncertain what should happen now , I'm Now at the moment trying to get the opencv-qt-for-all package from ccr community repository and let the program handle these issues by it self, but I'm sure it won't fix my problem] :
QT += core
QT -= gui
TARGET = FirstOpenCV
CONFIG += console
CONFIG -= app_bundle
CONFIG += link_pkgconfig
PKGCONFIG += opencv
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += /usr/local/include/opencv2/
#LIBS += -L/usr/local/lib/ \
#-libopencv_core.so \
#-libopencv_highgui.so \
#-libopencv_imgproc.so \
#-libopencv_features2d \
#-libopencv_calib3d.so
LIBS += /usr/lib/libopencv_core.so \
/usr/lib/libopencv_highgui.so \
/usr/lib/libopencv_imgproc.so \
/usr/lib/libopencv_features2d.so \
/usr/lib/libopencv_calib3d.so \
/usr/lib/libavcodec.so
And here's The Code :
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
int main() {
// read an image
Mat image = imread("002.jpg");
// create image window named "My Image"
namedWindow("My Image");
// show the image on window
imshow("My Image", image);
// wait key for 5000 ms
waitKey(5000);
return 0;
}

Try:
QT += core
QT -= gui
TARGET = FirstOpenCV
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += /usr/local/include/opencv2/
LIBS += -LC:/usr/local/lib/ \
-lopencv_core \
-lopencv_highgui \
-lopencv_imgproc \
-lopencv_features2d \
-lopencv_calib3d

It seems it fails on your LIBS declaration.
Can you try this:
LIBS += -LC:/usr/local/lib/ \
-libopencv_core.so.2.4.2 \
-libopencv_highgui.so.2.4.2 \
-libopencv_imgproc.so.2.4.2 \
-libopencv_features2d.so.2.4.2 \
-libopencv_calib3d.so.2.ss4.2
Please notice the backslashes at the end of the lines. Without those, the next line is parsed as a separate declaration and "-libopencv_core.so.2.4.2" by itself is not a valid declaration.

I've never seen using C:/ on Unix: then this could be a required correction (also accounts for #enderland answer):
LIBS += -L/usr/local/lib/ \
-lopencv_core \
-lopencv_highgui \
-lopencv_imgproc \
-lopencv_features2d \
-lopencv_calib3d
I had some problem on my system when upgraded to OpenCV 2.4.2 - The runtime was bound to previous version, bundled with the OS. I had to (painfully) recompile and reinstall OpenCV, and in the way I found a nice 'trick': use pkgconfig instead of hard coding the paths:
CONFIG += link_pkgconfig
PKGCONFIG += opencv

the problem is solved , as i said before , my program executed but with an error the problem was the Picture Directory, i've put it in the source file beside main.cpp the problem is that if u want to get a real result Using Debug Or Release Mode u should actually put the picture in those two directories and then run Make another time.
If u are willing to run it through the same directory that i used which was the source file, u should open an terminal or just press F4 in ur Dolphin File Manager or whatever u use and first run qmake then call the make and u are good to go, another problem was my OS (chakra) won't let mounted devices to have an Executable Permission so u have to move ur project to Home or Where ever u prefer inside the environment of ur OS.
SOLVED...:) Tnx every one:)

Related

How can I resolve “QML module not found” within Qt Creator

This question is related to the unanswered “Display video in Qml via Gstreamer qmlglsink plugin” question as I have the same problem.
The issue is that Qt Creator cannot find whatever file is necessary to resolve the import “org.freedesktop.gstreamer.GLVideoItem 1.0” statement.
When I create a new QML project and add the import “org.freedesktop.gstreamer.GLVideoItem 1.0” line. I get this error. The project compiles and runs fine.
I have another project taken from an example I downloaded. It uses GstGLVideoItem within its qml file. It also gives the same error and it also compiles and runs fine. It plays the Big Buck Bunny video from a file without issue.
I have totally rebuilt my computer trying to resolve this. Reinstalled Qt 5.15.2 using the online installer and GStreamer 1.18.0 following the instructions on the GStreamer website into an Ubuntu 20.10 PC. Both Qt and GStreamer are working as expected. I have been able to build and run any desired Qt Example without issue. I have also been able to compile and run any of the GStreamer tutorials as well as my own custom pipelines using C and gst-launch-1.0.
This issue occurs within Qt Creator when I bring the two together and try to display a GStreamer video in QML.
I’m new to Linux, Qt, GStreamer, qmake, cmake… How can I debug this? What kind of file is the import statement looking for? Is it a .qml file or some other kind of file? How would I find the files exact name to see if it exists?
Here is the contents of the .pro file for the project that displays the video. I have tried most everything I can find online to resolve this, but no joy.
TEMPLATE = app
QT += qml quick widgets
CONFIG += qml_debug
QT_CONFIG -= no-pkg-config
CONFIG += link_pkgconfig debug
PKGCONFIG += \
gstreamer-1.0 \
gstreamer-sdp-1.0 \
gstreamer-gl-prototypes-1.0 \
gstreamer-gl-1.0 \
gstreamer-gl-egl-1.0 \
gstreamer-app-1.0 \
gstreamer-net-1.0 \
gstreamer-video-1.0 \
gstreamer-controller-1.0 \
gstreamer-rtsp-1.0 \
gstreamer-plugins-base-1.0 \
gstreamer-pbutils-1.0 \
gstreamer-check-1.0 \
gstreamer-allocators-1.0 \
gstreamer-rtp-1.0 \
gstreamer-riff-1.0 \
gstreamer-tag-1.0 \
gstreamer-audio-1.0 \
gstreamer-gl-x11-1.0 \
gstreamer-fft-1.0 \
gstreamer-base-1.0
CONFIG += c++17
INCLUDEPATH += /usr/include/gstreamer-1.0/
INCLUDEPATH += /usr/include/glib-2.0/
INCLUDEPATH += /usr/lib/x86_64-linux-gnu/glib-2.0/include/
DEFINES += GST_USE_UNSTABLE_API
INCLUDEPATH += ../lib
SOURCES += main.cpp \
qmlplayer.cpp \
setplaying.cpp
RESOURCES += qmlsink.qrc
QML_IMPORT_PATH += /usr/lib/x86_64-linux-gnu/gstreamer-1.0
QML_IMPORT_PATH += /usr/lib/x86_64-linux-gnu/gstreamer1.0/gstreamer-1.0
QML_IMPORT_PATH += /lib/x86_64-linux-gnu/gstreamer-1.0
HEADERS += \
qmlplayer.h \
setplaying.h
Matthew Waters on the GStreamer forum has answered this question.
I quote him below.
Ah, so your problem is use with the Qt designer not showing finding the
relevant qml code. That use case is currently not supported by qmlglsink.
The issue is that the necessary QML item is contained within the
qmlglsink element itself and is registered dynamically when the element
itself is instantiated. Qt designer doesn't know anything about
GStreamer so cannot perform this initialisation for you. There are no
qmldir or qmltype files for qmlglsink.
The 'fix' involves are rather complicated restructure of the qmlglsink
element to support placing the qml part/plugin in a separate .so that is
findable with Qt tools (using qmldir or whatever).
You might have to dynamicaly register the module before loading the qml on your main as below.
qmlRegisterType<QtGLVideoItem> ("org.freedesktop.gstreamer.GLVideoItem", 1, 0, "GstGLVideoItem");
You will have to create the QtGLVideoItem object which inherits the QtQuickItem class, please see below.
#include <QQuickItem>
class QtGLVideoItem : public QQuickItem
{
Q_OBJECT
public:
QtGLVideoItem();
~QtGLVideoItem();
protected:
private:
};

Qt project, no rule to make target needed by

I have a problem with my Makefile. I downloaded opensource Qt project. Hence, when I try to compile it I got a message:
error: No rule to make target needed by stop.
In my .pro file I have relative paths to *.cpp files. So when I replace relative paths to absolute it works, another case it got me with the error above.
System is Linux.
What should I do to do this work with the relative paths?
I would use QtCreator, opening the project and then adding one of the misplaced sources (let say the first you see in .pro).
The IDE should place it with the correct relative path, as appropriate per your folder choice. After that cut'n'paste the path prefix all over the remaining places.
Anyway, path prefixes should be relative to the directory where you find the .pro. An example from an opensource project I'm using (QZXIng, a Qt port of ZXing):
SOURCES += CameraImageWrapper.cpp \
QZXing.cpp \
imagehandler.cpp \
zxing/ResultPointCallback.cpp \
zxing/ResultPoint.cpp \
zxing/Result.cpp \
...
so you could try to move the .pro file where appropriate instead of changing relative paths...
One reason for this issue is because you have removed a file which you no longer need but forgot remove from res.qrc
I had this issue and it was because I had the wrong Kit selected under Projects>Build & Run
I have the same error. My pro file was
HEADERS = \
charectertranformer.h \
filereader.h \
svgview.h \
threadfilereader.h \
serverworker.h \
renderserver.h
SOURCES = \
charectertranformer.cpp \
filereader.cpp \
main.cpp \
svgview.cpp \
threadfilereader.cpp \
serverworker.cpp \
renderserver.cpp \
QT += concurrent
QT += opengl
QT += network
QT += svg
CONFIG -= console
#CONFIG += warn_off exceptions_off
#qmake -svgviewer.pro
deleting backslash after renderserver.cpp helps me

Run time error for a missing DLL which exists

I am writing a tool with Qt Creator which builds but immediately crashes with the message:
"The program can't start because pthreadVC2.dll is missing from your
computer. Try reinstalling the program to fix this problem".
Of course, the "pthreadVC2.dll" library is not missing (and is not corrupted, since it works with other projects), and it is located in the path specified in the Qt pro file:
# DeltaPlots.pro
TARGET = DeltaPlots
QT += core gui
CONFIG += console
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TEMPLATE = app
win32 {
INCLUDEPATH += S:\\3rdparty\\DFS.Infrastructure.ThreadingW \
S:\\3rdparty\\DFS.Infrastructure.File \
"C:\\path\\to\\boost\\boost_1_51_0"
win32-g++:LIBS += -L"S:\\lib\\" -lMyLib
win32-g++:LIBS += -L"S:\\3rdparty\\DFS.Infrastructure.File\\" -lDFS.Infrastructure.FileSystem
win32-g++:LIBS += -L"S:\\3rdparty\\DFS.Infrastructure.ThreadingW\\" -lDFS.Infrastructure.Threading -lpthreadVC2
}
SOURCES += MainWindow.cpp \
entrypoint.cpp
HEADERS += MainWindow.h
FORMS += MainWindow.ui
OTHER_FILES += ProjectList.txt \
ImageList.txt
Platform:
Windows 7
MinGW
Qt 4.8.3
Qt Creator 2.6.0
[Edit: This answer refers to the original question]
Usually you would add
LIBS += -LS:/3rdparty/DFS.Infrastructure.ThreadingW \
-lpthreadVC2
This adds your library's folder as a library search path (Note the capital -L) and pthreadVC2.lib as a library to link against (lower case -l).
You do not need to add the .dll to the LIBS path, as the .dll is loaded at runtime.
But: This approach only works when the .lib is in the same folder as the .dll. I'm a bit surprised you have yours in different locations.
Maybe adding
LIBS += -LS:/3rdparty
would work, but I'm not sure about that.
In any event, you need to deploy the .dll with your .exe for releases.

Qmake project dependencies (linked libraries)

I have a project that links to a number of shared libraries.
Lets say project A depends on projects B and C
Ideally, I want to impose the following dependencies in my project file:
Rebuild project A if either B or C has been rebuilt since last time project A was built
Use the output for the relevant configuration (i.e. if building project A in debug mode, then use the debug versions of the libs for project B and C)
Does anyone know how I may explicitly express such dependencies in my project file?
After quite a bit of frustration with qmake, I have found what I think is the answer to your question. If not, then I have learned the way that I will use qmake until I find something better, because this is still a little bit ugly. I set up a demo project, this is my directory structure (files have extensions, folders do not):
MyProj
MyProj.pro
myproj-core
myproj-core.pro
globals.h
MyProjCore.h
MyProjCore.cpp
myproj-app
myproj-app.pro
main.cpp
We start with MyProj.pro as a subdirs project, which is the key to doing what you ask. Basically, instead of depending on other projects to specify debug/release and all sorts of other junk, you just set it on the one qmake file. It doesn't let you make only what you need, but it's the best solution I could come up with. Here are the contents:
TEMPLATE = subdirs
# Needed to ensure that things are built right, which you have to do yourself :(
CONFIG += ordered
# All the projects in your application are sub-projects of your solution
SUBDIRS = myproj-core \
myproj-app
# Use .depends to specify that a project depends on another.
myproj-app.depends = myproj-core
myproj-core.pro is your typical shared object library:
QT -= gui
TARGET = myproj-core
TEMPLATE = lib
DEFINES += MYPROJCORE_LIBRARY
SOURCES += MyProjCore.cpp
HEADERS += MyProjCore.h \
globals.h
myproj-app.pro is consumer application, where the little rebuild-when-needed trick is:
QT -= gui
TARGET = myproj-app
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
# Specify that we're lookin in myproj-core. Realistically, this should be put
# in some configuration file
INCLUDEPATH += ../myproj-core
# Link to the library generated by the project. Could use variables or
# something here to make it more bulletproof
LIBS += ../myproj-core/libmyproj-core.so
# Specify that we depend on the library (which, logically would be implicit from
# the fact that we are linking to it)
PRE_TARGETDEPS += ../myproj-core/libmyproj-core.so
SOURCES += main.cpp
I hope this solves your problem, as I know it solved mine!
EDIT: I made a file specifically for building the dependencies for me, I store it in a sibling folder of each of my projects (child of the MyProj in the directory structure specified above) called dependencies.pri:
# On windows, a shared object is a .dll
win32: SONAME=dll
else: SONAME=so
# This function sets up the dependencies for libraries that are built with
# this project. Specify the libraries you need to depend on in the variable
# DEPENDENCY_LIBRARIES and this will add
for(dep, DEPENDENCY_LIBRARIES) {
#message($$TARGET depends on $$dep ($${DESTDIR}/$${dep}.$${SONAME}))
LIBS += $${DESTDIR}/lib$${dep}.$${SONAME}
PRE_TARGETDEPS += $${DESTDIR}/lib$${dep}.$${SONAME}
}
So at the bottom of all the consuming applications, I can add the lines:
DEPENDENCY_LIBRARIES = myproj-core
include(../config/dependencies.pri)
This assumes that you are copying the libraries to some shared location and/or moving them around as needed, so my function might not work for you, but I figured I would add it to the solution.
I use the solution below. This works without the usage of an extra .pro file with subdir template.
TEMPLATE = app
TARGET = MyApp
PRE_TARGETDEPS = ../../libs/MyLib/MyLib.a
INCLUDEPATH += ../../libs/MyLib/include
HEADERS += src/MyApp.h \
../../libs/MyLib/incude/MyLib.h
SOURCES += src/MyApp.cpp
LIBS += ../../libs/MyLib/MyLib.a
MyLib.target = ../../libs/MyLib/MyLib.a
MyLib.commands = cd ../../libs/MyLib && make
MyLib.depends = ../../libs/MyLib/Makefile
QMAKE_EXTRA_TARGETS += MyLib
Check out this question: Force relink when building in QT Creator
Try adding something similar to this code to your pro file:
CONFIG(debug, debug|release) {
DESTDIR = ../../../bin/debug
OBJECTS_DIR = ./debug
}
else {
DESTDIR = ../../../bin/release
OBJECTS_DIR = ./release
}
Then you will have to specify the dependencies for each configuration:
CONFIG(debug, debug|release) {
LIBS += -L../../../lib/debug \
-L../../../bin/debug \
-llib1 \
-llib2
PRE_TARGETDEPS += ../../../lib/debug/liblib1.a \
../../../lib/debug/liblib2.a
else {
LIBS += -L../../../lib/release \
-L../../../bin/release \
-llib1 \
-llib2
PRE_TARGETDEPS += ../../../lib/release/liblib1.a \
../../../lib/release/liblib2.a
}
I had this problem when refactoring my project, after I moved in a new DLL (pqXDot) a reusable class (from pqGraphviz).
After adding a new DLL to my project, and adding the new DLL reference to others DLL and applications that needed it, I had in main .pro:
TEMPLATE = subdirs
SUBDIRS += \
pqConsole \
pqConsoleTest \
pqSource \
pqSourceTest \
fdqueens \
pqGraphviz \
pqGraphvizTest \
pqXDot
and the rebuild caused a linker error, because pqGraphviz, the DLL being restructured, can't find pqXDot, the new DLL.
It turns out it's sufficient to reorder the SUBDIRS list, moving the required DLL before the dependent one:
SUBDIRS += \
pqConsole \
pqConsoleTest \
pqSource \
pqSourceTest \
fdqueens \
pqXDot \
pqGraphviz \
pqGraphvizTest
For those that are interested into a template for your Qt/QML project, I have published one template on GitHub QmlAppTemplate.

compiling maya (3d application ) with qt

including the maya ( 3d application ) classes in qt program gives lot of errors..... i have added all required include paths and libs...the same problem persists ....
this is pro file for my qt project
TARGET = FileCon
TEMPLATE = app
SOURCES += main.cpp \
dialog.cpp
HEADERS += dialog.h \
ConvertFunction.h
FORMS += dialog.ui
LIBS += "C:/Program Files/Autodesk/Maya2008/lib" \
-lOpenMaya.lib \
-lFoundation.lib \
-lOpenMayalib
INCLUDEPATH += "C:/Program Files/Autodesk/Maya2008/include"
DEFINES = _BOOL \
WIN32 \
REQUIRE_IOSTREAM
///////////////////////////////////////////
How is it possible to use maya classes with qt.
Try something like this
LIBS += $$quote(-LC:/Program Files/Autodesk/Maya2008/lib) \
-lOpenMaya \
-lFoundation
qmake LIBS variable
If you are using QtCreator with the included compiler on Windows, it expects ".a" style libraries, rather than Visual Studio ".lib" style libraries.
You still haven't given enough infromation about eaxctly what you are doing. (How are you building, what compiler, etc.) or what is going wrong (exact error messages) to know for sure if that's the issue. But, if my crystal ball is working well today, I'd recommend checking the library format.

Resources