Strange compilation error : undefined reference to ...
Hi,
I'm using QT Creator 2.1 under Win7 and with the following code I got this error :
error: undefined reference to `File::file_exists(QString const&) const'
The code
Code:
if ( _myfile.file_exists("test.txt") )
The class code
Code:
bool file_exists
(const QString & file) const;
I have the same problem with other files, by example
Code:
FinancialCategory* category = ...;
Product::get( category );
...
namespace Product {
bool get(Category* c)
}
And I got this error : error: undefined reference to `Product::get(FinancialCategory* c)'
If I do the following it works Product::get((Category*) category ) ... but it should be handled automatically ?
Thanks for your help
Re: Strange compilation error : undefined reference to ...
In such cases please state what are the steps you did so far:
header included, namespace resolution, include paths checked etc...
Re: Strange compilation error : undefined reference to ...
Thx,
I have this (There is too much code to put everything !):
"FinancialCategory.hh"
Code:
#include "Category.hh"
class FinancialCategory : public Category { ... }
"Product.hh"
Code:
namespace Product
{
bool get(Category* c);
}
"Product.cc"
Code:
namespace Product
{
bool get(Category* c) { ... }
}
It is very simple code... but can't face where is the problem !!!!
Re: Strange compilation error : undefined reference to ...
Yes, but what have you checked so far?
Did you check that you have included the correct header files?
Did you check that the all the paths in your projects are correct?
And all the other stuff you checked so that we don't have to guess if you made all the basic checks first.
Please show the code where you use the statements with more then just the line it self, since most probably the error is in the way you have structured you code.
You don't have to post all the code, but full relevant segments will be most helpful.
The small pieces of code you posted give no information on what you might be doing wrong.
Quote:
error: undefined reference to `Product::get(FinancialCategory* c)'
Wait a minute...
Do you have a virtual method in your Category class?