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. Strange Linker error LNK2019 MSVC2013-64 bits build dbg/rel with linkage to opencv 3.00 prebuilt library (.lib static 64-bits) on Win10/64bits
Forum Update on Monday, May 27th 2025

Strange Linker error LNK2019 MSVC2013-64 bits build dbg/rel with linkage to opencv 3.00 prebuilt library (.lib static 64-bits) on Win10/64bits

Scheduled Pinned Locked Moved General and Desktop
lnk201964 bitsopencv3.00linker errorsqmakelibdebugstatic linkingmsvc2013win10-64
4 Posts 2 Posters 4.0k Views
  • 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.
  • S Offline
    S Offline
    sun_sina
    wrote on 7 Oct 2015, 00:01 last edited by
    #1

    I extracted the OpenCV v3.00 to the C:\opencv3.0\ directory of my Win10/64bits Desktop PC and this package bundles pre-built static libraries (.lib) files for both x86 and x64 Windows Desktop platfrom.

    When I create a Qt Quick Application project in Qt 5.5 I choose desktop Qt 5.5.0 MSVC2013 64bit Kit Selection for both dbg and rel.
    In fact the OpenCV prebuild static libraries reside in "C:\opencv3.0\build\x86\vc12\staticlib" and "C:\opencv3.0\build\x64\vc12\staticlib".
    and those libraries are compiled with VC2012 but my Kit Selection is MSVC2013, that I guess is not the issue with my linkage error (LNK2019).
    I set following .pro file (so it would be 64/32 bit friendly by writing as follows.

     TEMPLATE = app
    
    QT += qml quick widgets
    SOURCES += main.cpp \
    	OpenCVExm.cpp
    
    RESOURCES += qml.qrc
    #unix:LIBS += -L/usr/local/lib -lmath
    #LIBPATH += C:\\opencv3.0\\build\\x86\\vc12\\staticlib
    
    CONFIG( debug, debug|release ) {
    win32:contains(QMAKE_HOST.arch, x86_64){
    
    	LIBS += -LC:/opencv3.0/build/x64/vc12/staticlib/
    		-llibjpegd
    		-lopencv_core300d
    		-lopencv_calib3d300d
    		-lopencv_contrib300d
    		-lopencv_features2d300d
    		-lopencv_flann300d
    		-lopencv_gpu300d
    		-lopencv_haartraining_engined
    		-lopencv_highgui300d
    		-lopencv_imgproc300d
    		-lopencv_legacy300d
    		-lopencv_ml300d
    		-lopencv_nonfree300d
    		-lopencv_objdetect300d
    		-lopencv_photo300d
    		-lopencv_stitching300d
    		-lopencv_superres300d
    		-lopencv_ts300d
    		-lopencv_video300d
    		-lopencv_videostab300d
    
    } else {
    
    	LIBS += -LC:/opencv3.0/build/x86/vc12/staticlib/
    		-llibjpegd
    		-lopencv_core300d
    		-lopencv_calib3d300d
    		-lopencv_contrib300d
    		-lopencv_features2d300d
    		-lopencv_flann300d
    		-lopencv_gpu300d
    		-lopencv_haartraining_engined
    		-lopencv_highgui300d
    		-lopencv_imgproc300d
    		-lopencv_legacy300d
    		-lopencv_ml300d
    		-lopencv_nonfree300d
    		-lopencv_objdetect300d
    		-lopencv_photo300d
    		-lopencv_stitching300d
    		-lopencv_superres300d
    		-lopencv_ts300d
    		-lopencv_video300d
    		-lopencv_videostab300d
    	}
    }
    
    
    
    INCLUDEPATH +="C:/opencv3.0/build/include"
    
    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH =
    
    # Default rules for deployment.
    include(deployment.pri)
    
    HEADERS += \
    	opencvexm.hpp
    

    And my project file (OpenCVExm.cpp/hpp) are as follow (very simple)

    OpenCVExm.cpp :

    #include "opencv2/core/core.hpp"
    #include "opencv2/highgui/highgui.hpp"
    #include <iostream>
    using namespace cv;
    using namespace std;
    int testOpenCV(void){
    	   namedWindow("MyWindow", CV_WINDOW_AUTOSIZE);
    	   return 0;
    }
    

    and opencvexm.hpp:

    #ifndef OPENCVEXM_HPP
    #define OPENCVEXM_HPP
    int testOpenCV(void);
    #endif // OPENCVEXM_HPP
    

    and the main.cpp file contents is:

    #include <QApplication>
    #include <QQmlApplicationEngine>
    #include "opencvexm.hpp"
    
    int main(int argc, char *argv[])
    {
    	QApplication app(argc, argv);
    
    	QQmlApplicationEngine engine;
    	engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    	testOpenCV();
    	return app.exec();
    }
    

    I tried following test/builds and before every build I cleaned the project then run qmake and lastly rebuild all the project.

    Even I tried to compile with Desktop MSVC2013 64bit Debug mode with following qmake command:
    qmake.exe "C:\OpenCV3\MyLearning\Qt Project\HW1\HW1\HW1.pro" -r -spec win32-msvc2013 "CONFIG+=debug" "CONFIG+=declarative_debug" "CONFIG+=qml_debug"

    and the release build as follows:

    qmake.exe "C:\OpenCV3\MyLearning\Qt Project\HW1\HW1\HW1.pro" -r -spec win32-msvc2013

    and I always get following linker error regardless of 32/64 dbg/rel

    OpenCVExm.obj:-1: error: LNK2019: unresolved external symbol "private: char * __cdecl cv::String::allocate(unsigned __int64)" (?allocate@String@cv@@AEAAPEAD_K@Z) referenced in function "public: __cdecl cv::String::String(char const *)" (??0String@cv@@QEAA@PEBD@Z)
    
    OpenCVExm.obj:-1: error: LNK2019: unresolved external symbol "private: void __cdecl cv::String::deallocate(void)" (?deallocate@String@cv@@AEAAXXZ) referenced in function "public: __cdecl cv::String::~String(void)" (??1String@cv@@QEAA@XZ)
    

    3 unresolved externals, I think I included all the required libraries but I do not know why I get linker error.

    I am wondering if win32:contains is only used for the 32 bit apps or it does not matter 32/64 bits platfrom, and how can I fix this problem.
    Please note that I included the debug libraries (their names end with 'd') ,do they need .pdb files included in the project!?
    Thanks

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 7 Oct 2015, 05:34 last edited by
      #2

      Usually on Windows you cannot mix different compilers, even not different versions of VC. So, this is most probably the issue.
      Try to build OpenCV with MSVC2013.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sun_sina
        wrote on 9 Oct 2015, 07:13 last edited by
        #3

        @jsulm
        I tried to re-build the OpenCV3.0 libraries in VisualStudio 2013 -64bits compiler environment
        and implement the freshly built static libraries an I get similar error in Qt.

        I can not figure out what is wrong going on.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 9 Oct 2015, 08:48 last edited by
          #4

          You can try to add your static libraries like this: LIBS += PATH_TO_LIB_DIR/libLIBNAME.lib

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          4/4

          9 Oct 2015, 08:48

          • Login

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