Extra characters after test expression.



  • Hi,
    I'm trying to set OpenCV (3.10) library with Qt (5.7) at Windows 7

    While building the sample project and I got that error "Extra characters after test expression" on my PRO file

    Here is the

    QT       += core
    QT       -= gui
    TARGET = myFirstOpenCVProject
    CONFIG   += console
    CONFIG   -= app_bundle
    TEMPLATE = app
    SOURCES += main.cpp
    INCLUDEPATH += E:\\opencv\\release\\include\\
    LIBS += -LE:\\opencv\\release\\x86\\mingw\\lib \
        -llibopencv_imgcodecs310.dll.a
        -llibopencv_core310.dll.a \
        -llibopencv_highgui310.dll.a \
        -llibopencv_imgproc310.dll.a \
        -llibopencv_features2d310.dll.a \
        -llibopencv_calib3d310.dll.a
    

    Here is C code

    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    
    int main()
    {
            cv::Mat image= cv::imread("img.jpg");
            cv::namedWindow("My Image");
            cv::imshow("My Image", image);
            cv::waitKey(5000);
            return 1;
    }
    

    Thanks at advance



  • you are missing a back slash after -llibopencv_imgcodecs310.dll.a and -l libraries should not include the extension



  • Thank you for reply.

    Now my PRO file is the following

    QT       += core
    QT       -= gui
    TARGET = myFirstOpenCVProject
    CONFIG   += console
    CONFIG   -= app_bundle
    TEMPLATE = app
    SOURCES += main.cpp
    INCLUDEPATH += E:\\opencv\\release\\include\\
    LIBS += -LE:\\opencv\\release\\x86\\mingw\\lib \
        -llibopencv_imgcodecs310 \
        -llibopencv_core310 \
        -llibopencv_highgui310 \
        -llibopencv_imgproc310 \
        -llibopencv_features2d310 \
        -llibopencv_calib3d310
    

    and got errors like that undefined reference to `cv::String::allocate(unsigned int)'

    seems include directory have problem



  • @Vics said in Extra characters after test expression.:

    Thank you for reply.

    Now my PRO file is the following

    QT += core
    QT -= gui
    TARGET = myFirstOpenCVProject
    CONFIG += console
    CONFIG -= app_bundle
    TEMPLATE = app
    SOURCES += main.cpp
    INCLUDEPATH += E:\opencv\release\include\
    LIBS += -LE:\opencv\release\x86\mingw\lib
    -llibopencv_imgcodecs310
    -llibopencv_core310
    -llibopencv_highgui310
    -llibopencv_imgproc310
    -llibopencv_features2d310
    -llibopencv_calib3d310

    and got errors like that undefined reference to `cv::String::allocate(unsigned int)'

    seems include directory have problem

    Drop the lib from the libraries.. i.e.

    LIBS += -lopencv_core310 \
       opencv_highgui310
       etc
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.