compiler error

  • Thread starter christos panagiotou
  • Start date
C

christos panagiotou

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
 
V

Victor Bazarov

christos panagiotou said:
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

The most probable cause for this error is that you forget
to add the file that contains the InsertNextCell function
to the final program. How to do that is governed by the
compiler command-line options and switches and not by the
language rules. Since you seem to be using G++, you should
probably ask in gnu.g++.help how to set up your project.

Victor
 
D

David White

christos panagiotou said:
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

So, you are convinced that the definition is there, and your compiler is
convinced that it isn't. How can anyone here possibly help without any
samples of code?

Try moving the function "vtkUnstructuredGrid::InsertNextCell(int,
vtkIdList*)" from where it is to main.cpp, and see what happens. If the
error goes away then clearly your compiler is not coming across the function
in the other file. This could be because the code is excluded by an #ifdef
or the like, or because you are not including the file, despite your
certainty that you are.

David
 
C

Chris Theis

christos panagiotou said:
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

Did you add the paths to the vtk libraries to your project? The linker
doesn't know where to find vtkUnstructuredGrid::InsertNextCall and complains
about it. Thus I assume that you forgot to set the library paths.

HTH
Chris
 
X

Xavier Decoret

christos said:
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: (e-mail address removed) |
| home : http://www.graphics.lcs.mit.edu/~decoret|
+-------------------------------------------------+
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top