Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Extra characters after test expression.
Forum Updated to NodeBB v4.3 + New Features

Extra characters after test expression.

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 3.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vics
    wrote on last edited by VRonin
    #1

    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

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

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

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      3
      • V Offline
        V Offline
        Vics
        wrote on last edited by VRonin
        #3

        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

        A 1 Reply Last reply
        0
        • V Vics

          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

          A Offline
          A Offline
          ambershark
          wrote on last edited by
          #4

          @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
          

          My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved