christos panagiotou wrote:
> hi all
>
> I am getting the following error when i try to compile a source file:
>
> /home/christos/VIVE02/project/asm_3d/asm_3d/main.cpp:57: undefined
> reference to `vtkUnstructuredGrid::InsertNextCell(int, vtkIdList*)'
> collect2: ld returned 1 exit status
>
> I have double checked that:
> 1.the .h and .cxx files i have for InsertNextCell exist and their
> definiton of InsertNextCell is the same with the one I am calling
>
> 2. I have double checked that I include the .h file with the correct
> path in the project options (I use KDevelop)
>
> I dont know what is wrong
> I would be greatfull for any help
> thanks
> Christos Panagiotou
>
A problem that can occur with gcc is if you accidentally moved the body
of the function from the .h where you typed it initially to the .cpp
where it finally is. If you forget a leading "inline", the linker won't
find the function.
ex:
//file a.h
//------
struct A
{
void doIt() const;
}
//file a.cpp
//------
inline void A::doIt() const // Ah! The inline is the culprit!
{
cout<<"done!\n";
}
//file main.C
//----------
#include "a.h"
#include <iostream>
using namespace std;
int
main(int,char**)
{
A a;
a.doIt();
return 0;
}
The aboce example won't link on gcc3.3
--
+-------------------------------------------------+
| Xavier Décoret - Post Doct |
| Graphics Lab (LCS) - MIT |
| mailto:
|
| home : http://www.graphics.lcs.mit.edu/~decoret|
+-------------------------------------------------+