-2

I got a problem compiling the source that follows:

    QString code = this->viewManager()->activeView()->document()->text();
    Qualifier qua;
    qua.setQCode(code);

It tells me that

error: undefined reference to `Qualifier::setQCode(QString)'

the code of the qualifier.h and .cpp follows

#ifndef __QUALIFIER_H__
#define __QUALIFIER_H__

#include <iostream>
#include <string>
#include <QString>
#include <queue>
#include "analyser.h"



using namespace std;



class Qualifier
{

private:

    string code;
    queue<method> tokenisedCode;
    //queue<analysis> analysedCode;

void tokeniseCode();

public :


void setCode(string code);

void setQCode(QString code);

void computeLocAnalysis();

void computeCCAnalysis();

void visualiseResults();


};

 #endif /* __QUALIFIER_H__ */

and the CPP is

#include "qualifier.h"

using namespace std;


void Qualifier::tokeniseCode()
{

Parser par;
par.setCode(code);
par.parse();
this->tokenisedCode = par.getMethods();

}

void Qualifier::setCode(string code)
{
    this->code = code;
}

void Qualifier::setQCode(QString code)
{
this->code = qPrintable(code);
}

void Qualifier::computeLocAnalysis()
{

std::cout << this->code << std::endl;

/*
locAnalyser ana = new locAnalyser();
ana.setMethodList(tokenisedCode);
ana.computeResult();
this->analysedCode = ana.getResult();
*/
 }

void Qualifier::computeCCAnalysis()
{

// To be implemented;

 }

void Qualifier::visualiseResults()
{
/*
//Need a grapher of the results
while(!analysedCode.empty())
{
    analysis meth = analysedCode.front();
    cout << "LOC: " << meth.result << "\t\t" << meth.name << endl;
    analysedCode.pop();
    cout << "------------------------------------" << endl;
}
*/
}

I do not understand why the reference is not seen! I mean, is the exact thing, the same way that is done in the rest of the project!

user1384636
  • 481
  • 6
  • 17

4 Answers4

6

According to the header file you have 2 different implementations of similar functions:

void setCode(string code);

void setQCode(QString code);

But in the .cpp you only implement the first:

void Qualifier::setCode(string code)
{
    this->code = code;
}

Therefore the compiler complains about the missing setQCode().

Solution: either implement it or remove it's definition from the header file.

karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • done. there was the implementation, just it was not in this post. Now there is and the problem persists.... – user1384636 May 09 '12 at 13:18
  • How many source files do you have in this project? It may be simply that they are not being linked appropriately. – karlphillip May 09 '12 at 13:22
  • It is an open source project, Kate of KDE. I must add a feature, thus I simple added a folder in the project and the added files – user1384636 May 09 '12 at 13:29
  • It seems you need to edit the configuration files that are used to build the project and add the filenames of the sources you created :) – karlphillip May 09 '12 at 14:10
0

You didn't show us yout implementation of Qualifier::setQCode(QString) in .cpp file.

Maybe the argument from implementation cpp file does not match the argument of prototype from header file.

gal
  • 16
  • 1
0

You have 2 functions

void setCode(string code);

void setQCode(QString code);

May you've forgotten to implement setQCode??

m8labs
  • 3,671
  • 2
  • 30
  • 32
0

This is reported by linker, isn't it? I looks like the particular translation unit or library containing definition of 'Qualifier' class is not included in linking process.