Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt Creator Brain Computer Interface App Linker Problem



  • Dear Ladies and Gentelmen,

    i am working on a Brain Computer Interface and when i am done with the Errors i have now thirteen LNK2019 and one LNK2001 in the Multiscale Principal Component Analisys Function. So please can you help me cause i am doing my Master thisis and i am having such problemes since one mongth.

    Thank you deeply in advance,
    Best regards,
    Y.Zarca

    the includes are:

    #include <iostream>
    #include <string>
    #include <Eigen/Dense>    //Matrix Processing Lib
    
    #include <algorithm>
    
    #include <QList>
    #include <QSharedPointer>
    #include <QMetaType>
    
    #include "wavelet2d.h"        // Wavlet Transfotmation Lib
    #include "dataanalysis.h"     // Principal Component Analisys Lib
    #include "ap.h"               // Principal Component Analisys Lib for Matrixes
    

    and the function is:

    QList<Eigen::MatrixXd> DataAquisition::MSPCA (QList<Eigen::MatrixXd> Array, int LEVEL, std::string WNAME, int NPC) {
        int Size = Array.size();
    
        QList<Eigen::MatrixXd> AllOutput;
    
        for (int i = 0; i<Size; i++){
    
            Eigen::MatrixXd ArrayValue = Array.value(i);
            Eigen::MatrixXd Output;//(ArrayValue.size());
    
            for (int j = 0; j<ArrayValue.rows(); j++){
                Eigen::VectorXd Row = ArrayValue.row(j);
                std::vector<double> Signal(Row.data(), Row.data() + Row.size());
                std::vector<double> dwt_output;
                std::vector<double> flag;
                std::vector<int> lengths;
    
                if (ArrayValue.cols()%2==0)
                    flag = {0,0};
                else
                    flag = {1,0};
    
                dwt(Signal, LEVEL, WNAME, dwt_output, flag,  lengths);
    
    
                alglib::real_2d_array x;    x.setcontent(1, lengths[0],&dwt_output[0]);
                alglib::ae_int_t npoints;   npoints = lengths[0];
                alglib::ae_int_t nvars;     nvars = 1;
                alglib::ae_int_t info;
                alglib::real_1d_array s2;
                alglib::real_2d_array v;
                const alglib::xparams _params = alglib::xdefault;
    
                alglib::pcabuildbasis(x, npoints, nvars, info, s2, v, _params);
    
    
                QVector<double> V;
                for (int j1=0; j1<v.rows(); j1++)
                    for (int j2=0; j2<v.rows(); j2++)
                        V.append(v.operator()(i,j));
    
                double max = *std::max_element(V.constBegin(), V.constEnd());
    
                alglib::real_2d_array s; s.setcontent(1, s2.length(), s2.getcontent());
                alglib::real_2d_array Enh_v; Enh_v.setcontent(1, 1, &max);
                alglib::real_2d_array Enh_Sig;
                alglib::rmatrixgemm(1,s2.length(),1, 1, Enh_v,0,0,0, s,0,0,0, 0, Enh_Sig,0,0);;
    
                QVector<double> dwtop;
                for (int j1=0; j1<Enh_Sig.rows(); j1++)
                    for (int j2=0; j2<Enh_Sig.rows(); j2++)
                        dwtop.append(Enh_Sig.operator()(i,j));
    
                std::vector<double> dwtopV = dwtop.toStdVector();
                std::vector<double> idwt_output;
                idwt(dwtopV,flag, WNAME,idwt_output,lengths);
    
                double * idwt_data = idwt_output.data();
                Output.row(j) = Eigen::Map<Eigen::VectorXd>(idwt_data, Row.size());
            }
            AllOutput.append(Output);
        }
        return AllOutput;
    

    and the Errors are:

    dataaquisition.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) void * __cdecl dwt(class std::vector<double,class std::allocator<double> > &,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::vector<double,class std::allocator<double> > &,class std::vector<double,class std::allocator<double> > &,class std::vector<int,class std::allocator<int> > &)" (__imp_?dwt@@YAPEAXAEAV?$vector@NV?$allocator@N@std@@@std@@HV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@00AEAV?$vector@HV?$allocator@H@std@@@2@@Z) referenced in function "public: class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> > __cdecl DataAquisition::MSPCA(class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> >,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?MSPCA@DataAquisition@@QEAA?AV?$QList@V?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@@@V2@HV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z)
    =====================================================================
    dataaquisition.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) void * __cdecl idwt(class std::vector<double,class std::allocator<double> > &,class std::vector<double,class std::allocator<double> > &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::vector<double,class std::allocator<double> > &,class std::vector<int,class std::allocator<int> > &)" (__imp_?idwt@@YAPEAXAEAV?$vector@NV?$allocator@N@std@@@std@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@0AEAV?$vector@HV?$allocator@H@std@@@2@@Z) referenced in function "public: class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> > __cdecl DataAquisition::MSPCA(class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> >,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?MSPCA@DataAquisition@@QEAA?AV?$QList@V?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@@@V2@HV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z)
    =====================================================================
    dataaquisition.obj:-1: error: LNK2019: unresolved external symbol "public: double * __cdecl alglib::real_1d_array::getcontent(void)" (?getcontent@real_1d_array@alglib@@QEAAPEANXZ) referenced in function "public: class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> > __cdecl DataAquisition::MSPCA(class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> >,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?MSPCA@DataAquisition@@QEAA?AV?$QList@V?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@@@V2@HV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z)
    =====================================================================
    dataaquisition.obj:-1: error: LNK2019: unresolved external symbol "public: __int64 __cdecl alglib::ae_matrix_wrapper::rows(void)const " (?rows@ae_matrix_wrapper@alglib@@QEBA_JXZ) referenced in function "public: class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> > __cdecl DataAquisition::MSPCA(class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> >,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?MSPCA@DataAquisition@@QEAA?AV?$QList@V?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@@@V2@HV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z)
    =====================================================================
    dataaquisition.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl alglib::real_2d_array::real_2d_array(void)" (??0real_2d_array@alglib@@QEAA@XZ) referenced in function "public: class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> > __cdecl DataAquisition::MSPCA(class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> >,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?MSPCA@DataAquisition@@QEAA?AV?$QList@V?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@@@V2@HV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z)
    =====================================================================
    dataaquisition.obj:-1: error: LNK2019: unresolved external symbol "public: virtual __cdecl alglib::real_2d_array::~real_2d_array(void)" (??1real_2d_array@alglib@@UEAA@XZ) referenced in function "public: class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> > __cdecl DataAquisition::MSPCA(class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> >,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?MSPCA@DataAquisition@@QEAA?AV?$QList@V?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@@@V2@HV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z)
    =====================================================================
    dataaquisition.obj:-1: error: LNK2019: unresolved external symbol "public: double & __cdecl alglib::real_2d_array::operator()(__int64,__int64)" (??Rreal_2d_array@alglib@@QEAAAEAN_J0@Z) referenced in function "public: class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> > __cdecl DataAquisition::MSPCA(class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> >,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?MSPCA@DataAquisition@@QEAA?AV?$QList@V?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@@@V2@HV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z)
    =====================================================================
    dataaquisition.obj:-1: error: LNK2019: unresolved external symbol "public: void __cdecl alglib::real_2d_array::setcontent(__int64,__int64,double const *)" (?setcontent@real_2d_array@alglib@@QEAAX_J0PEBN@Z) referenced in function "public: class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> > __cdecl DataAquisition::MSPCA(class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> >,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?MSPCA@DataAquisition@@QEAA?AV?$QList@V?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@@@V2@HV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z)
    =====================================================================
    dataaquisition.obj:-1: error: LNK2019: unresolved external symbol "void __cdecl alglib::rmatrixgemm(__int64,__int64,__int64,double,class alglib::real_2d_array const &,__int64,__int64,__int64,class alglib::real_2d_array const &,__int64,__int64,__int64,double,class alglib::real_2d_array const &,__int64,__int64,struct alglib::xparams)" (?rmatrixgemm@alglib@@YAX_J00NAEBVreal_2d_array@1@0001000N100Uxparams@1@@Z) referenced in function "public: class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> > __cdecl DataAquisition::MSPCA(class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> >,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?MSPCA@DataAquisition@@QEAA?AV?$QList@V?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@@@V2@HV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z)
    =====================================================================
    dataaquisition.obj:-1: error: LNK2019: unresolved external symbol "void __cdecl alglib::pcabuildbasis(class alglib::real_2d_array const &,__int64,__int64,__int64 &,class alglib::real_1d_array &,class alglib::real_2d_array &,struct alglib::xparams)" (?pcabuildbasis@alglib@@YAXAEBVreal_2d_array@1@_J1AEA_JAEAVreal_1d_array@1@AEAV21@Uxparams@1@@Z) referenced in function "public: class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> > __cdecl DataAquisition::MSPCA(class QList<class Eigen::Matrix<double,-1,-1,0,-1,-1> >,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?MSPCA@DataAquisition@@QEAA?AV?$QList@V?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@@@V2@HV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z)
    =====================================================================
    dataaquisition.obj:-1: error: LNK2001: unresolved external symbol "struct alglib::xparams const & const alglib::xdefault" (?xdefault@alglib@@3AEBUxparams@1@EB)
    =====================================================================
    debug\MNE-BCI.exe:-1: error: LNK1120: 14 unresolved externals
    =====================================================================
    

    [Added code tags ~kshegunov]


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Are you sure you are linking to all the required libraries ?
    Of the correct architecture ? And if they are C++ built from the correct compiler ?



  • Dear Mr. @SGaist thank you so much for your reply. My .pro file data are as follow:

    INCLUDEPATH += "C:\src\win32\eigen"
    
    INCLUDEPATH += "C:\src\win32\wavelib\MSVCDLL\src"
    INCLUDEPATH += "C:\src\win32\alglib\src"
    
    INCLUDEPATH += "C:\src\win32\emd-master\src"
    
    SOURCES += \
        dataaquisition.cpp \
        featureextraction.cpp \
        knn.cpp \
        main.cpp
    
    HEADERS += \
        dataaquisition.h \
        featureextraction.h \
        knn.h
    
    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../../../../../src/win32/wavelib/MSVCDLL/release/ -lwavelet2d
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../../../../../src/win32/wavelib/MSVCDLL/debug/ -lwavelet2d
    else:unix: LIBS += -L$$PWD/../../../../../../../../../src/win32/wavelib/MSVCDLL/ -lwavelet2d
    
    INCLUDEPATH += $$PWD/../../../../../../../../../src/win32/wavelib/MSVCDLL/Release
    DEPENDPATH += $$PWD/../../../../../../../../../src/win32/wavelib/MSVCDLL/Release
    
    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../../../../../src/win32/wavelib/MSVCDLL/release/ -lwavelet2d
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../../../../../src/win32/wavelib/MSVCDLL/debug/ -lwavelet2d
    else:unix: LIBS += -L$$PWD/../../../../../../../../../src/win32/wavelib/MSVCDLL/ -lwavelet2d
    
    INCLUDEPATH += $$PWD/../../../../../../../../../src/win32/wavelib/MSVCDLL/Debug
    DEPENDPATH += $$PWD/../../../../../../../../../src/win32/wavelib/MSVCDLL/Debug
    
    

    i add the libraries through "Add Library" -> External Library ... .


  • Lifetime Qt Champion

    Which compiler are you currently using ?
    Which architecture are you targeting ?



  • Dear @SGaist i am just developing an enhancment feature for an open scource program as part of the Master thesis. so there is just the 3 classef for Data Aquisition, feature extraction and signal classification. The program is intended to run inside the bigger one, which is running 100%. In those classes everyting compiles perfectly besids Data Aquisition that needs this Function (MSPCA). So this is the architecture.

    And for the Compiler here is a screenshut:
    2021-03-29.png

    Thank you so much in advance


  • Lifetime Qt Champion

    These are the compilers you installed. Which exact version of Qt are you using ? Which compiler was used for the libraries you are using ?



  • Dear @SGaist thank you again. The following Pictures discribe the used kit version (5.15.1) and its compiler.

    Kits.png

    2021-03-30 (1).png


  • Lifetime Qt Champion

    @Y-Zarca Please also answer the last question. Reason: you can't mix different compilers. If the lib was build using different compiler than the one you're using it will not work.



  • Dear @jsulm i am so sorry for missunderstanding the question.

    wavelet2d compiler is MSVC++
    for ALGLIB this is what their Website Dokumentation say:

    ALGLIB is compatible with any C++ compiler which:
    
    supports 32-bit and 64-bit signed integer datatypes
    emits code which handles comparisons with IEEE special values without raising exception. We don't require that x/0 will return INF. But at least we must be able to compare double precision value with infinity or NAN without raising exception.
    All modern compilers satisfy these requirements.
    
    However, some very old compilers (ten years old version of Borland C++ Builder, for example) may emit code which does not correctly work with IEEE special values. If you use one of these old compilers, we recommend you to run ALGLIB test suite to ensure that library works.
    

    Thank you so much in advance.


  • Lifetime Qt Champion

    The question is: which version of MSVC was used to build that library ?
    And beside that, did you check whether you have a 32 or 64 bit build of that library ?



  • Dear @SGaist after a long search i can say that boath Libraries are Old:

    deppending on this Answer (https://stackoverflow.com/a/20911055) i think wavelet2d is built on VS 2010.

    As for ALGLIB the Copy Rights are dated on 2007. But cause i have just the .h & .cpp file dose the compiler compatibility a problem?

    And i could not know as well if those are a 32 or 64 Libraries.
    I am very sorry for the lack of info.


  • Lifetime Qt Champion

    VS2010 is only compatible with VS2010. Visual Studio started to have backward compatibility starting with VS2017 (meaning that you can use libraries from VS2015 with it and vice-versa).

    As for ALGLIB, their website does not agree with you. It looks like you have an old version of it. You should consider using a more recent version which from a quicklook at the manual seems not overly complicated to integrate into your application.



  • If you have access to the code it might be worth compiling the libraries with a more modern compiler. Then you can control whether is it 32 or 64 bit and make sure all your code uses the same compiler. If that is not an option I am afraid you could be stuck with whatever compiler was used to build the libraries. Not ideal.


  • Lifetime Qt Champion

    @fcarney the library is OpenSource and I have linked to it in my previous message.



  • Hi Everyone and thank you so much for your help. Actually i have solved the Problem of the Linker by adding the Source Code of the libraries to my Ptoject (Add Existing Files .... / Add Existing Directory .... ) to bypass the linker. So thank you so much.


  • Banned

    This post is deleted!

  • Banned

    This post is deleted!

Log in to reply