简体   繁体   English

无法使用Qt环境解析Linux中的库

[英]Cannot Parse Libraries In Linux Using Qt Enviornment

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 ur 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... : 经过一些有用的提示后,这是本文的新版本,问题是我的程序似乎正在以某种方式运行,但它只会发出一些错误...我不知道它实际上在说什么,因为已安装了库,我将路径形式LIBS + = LC:/usr/local/lib/ \\更改为LIBS += -L/usr/local/lib/ \\就像有人说的那样,当您使用linux(chakra)时,它实际上是指Windows。然后在目录末尾添加“ \\”,并将pkg-config添加到我的.pro文件中,所以这是新问题的新版本...:

    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] : 这是我的.pro配置[正如您所看到的,我已经评论(#)两个LIBS配置之一,我只是想问问哪一个更准确或更有用,昨天我尝试过,它发布了与更高版本的libavcodec,所以我搜索了一些文件并下载了libavcodec.53并对其进行了配置,但我不确定现在该怎么办,我现在想从ccr社区存储库中获取opencv-qt-for-all软件包,并让该程序自行处理这些问题,但我确定它不会解决我的问题]:

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. 看来您的LIBS声明失败。

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. 如果没有这些声明,则下一行将被解析为单独的声明,并且“ -libopencv_core.so.2.4.2”本身不是有效的声明。

I've never seen using C:/ on Unix: then this could be a required correction (also accounts for @enderland answer): 我从未见过在Unix上使用C:/:那么这可能是必需的更正(也占@enderland的答案):

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. 升级到OpenCV 2.4.2时,我的系统出现了一些问题- 运行时绑定到了与操作系统捆绑在一起的先前版本。 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: 我不得不(痛苦地)重新编译并重新安装了OpenCV,并以此方式找到了一个不错的“窍门”:使用pkgconfig而不是对路径进行硬编码:

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. 问题已经解决,如我之前所说,我的程序已执行,但出现错误,是图片目录,我将其放在main.cpp旁边的源文件中,问题是如果您想获得真实的结果调试或发布模式您实际上应该将图片放在这两个目录中,然后再运行Make。

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. 如果您愿意在我使用的与源文件相同的目录中运行它,则应该打开一个终端,或者在您的Dolphin File Manager中按F4键或使用任何您所使用的文件,然后先运行qmake然后调用make ,您就可以了。要走了,另一个问题是我的操作系统(chakra)不允许已挂载的设备具有可执行权限,因此您必须将项目移至Home或OS环境中您喜欢的任何位置。

SOLVED...:) Tnx every one:) 已解决... :) Tnx每一个:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM