Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Undefined reference to
Qt 6.12 LTS is out! See what's new in the release blog

Undefined reference to

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.7k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    @#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

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      Hi retroguy,

      Welcome to the Devnet forums.

      Could you post your error output more in detail?

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        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 >&)'

        1 Reply Last reply
        0
        • JohanSoloJ Offline
          JohanSoloJ Offline
          JohanSolo
          wrote on last edited by JohanSolo
          #4

          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;
           
          }
          

          `They did not know it was impossible, so they did it.'
          -- Mark Twain

          1 Reply Last reply
          0

          • Login

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