Undefined reference to



  • @#include <vector>
    #include <string>
    #include <vector>
    #include <QString>
    #include <QVector>
    #include <Method.h>

    using namespace::std;

    QVector<QString> bogus(vector<string> & vec)
    {
    QVector< QString > result;

    return result;
    

    }

    QVector<QVector <QString> > bogusMa(vector<vector<string> > & vec)
    {

    QVector< QVector<QString> > result;
    
    
    return result;
    

    }
    @

    @#include <QCoreApplication>
    #include <vector>
    #include <string>
    #include <QString>
    #include <QVector>
    #include <Method.h>

    using namespace std;

    int main(int argc, char *argv[])
    {

    QVector< QString> vec;
    
    QVector< QVector < QString> > mat;
    
    vector<string> vect;
    
    vector<vector<string> > matr;
    
    
    Method::bogus(vect);
    
    vec = Method::bogus(vect);
    
    mat = Method::bogusMa(matr);
    

    }
    @

    @#ifndef METHOD_H
    #define METHOD_H

    #include <vector>
    #include <string>
    #include <QString>
    #include <QVector>
    #include <Method.h>

    class Method{

    public:
    static QVector<QString> bogus(std::vectorstd::string & vec);
    static QVector<QVector <QString> > bogusMa(std::vector<std::vectorstd::string > & vec);

    };

    #endif // METHOD_H

    @

    I am not sure what's causing the error, but I know it has something to do with QStrings


  • Moderators

    Hi retroguy,

    Welcome to the Devnet forums.

    Could you post your error output more in detail?



  • error: undefined reference to `Method::bogusMa(std::vector<std::vector<std::string, std::allocatorstd::string >, std::allocator<std::vector<std::string, std::allocatorstd::string > > >&)'

    error: undefined reference to `Method::bogus(std::vector<std::string, std::allocatorstd::string >&)'



  • In the file where the functions bogus and bogusMa are defined, you're missing a Method::, it should read like this:

    QVector<QString> Method::bogus(vector<string> & vec)
    {
        QVector< QString > result;
     
     
        return result;
     
    }
    
    QVector<QVector <QString> > Method::bogusMa(vector<vector<string> > & vec)
    {
     
        QVector< QVector<QString> > result;
     
     
        return result;
     
    }
    

Log in to reply
 

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