Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > compiler error

Reply
Thread Tools

compiler error

 
 
christos panagiotou
Guest
Posts: n/a
 
      07-02-2003
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

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      07-02-2003
"christos panagiotou" <(E-Mail Removed)> wrote...
> 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


 
Reply With Quote
 
 
 
 
David White
Guest
Posts: n/a
 
      07-02-2003
christos panagiotou <(E-Mail Removed)> wrote in message
news:bdtfov$d74$(E-Mail Removed)...
> 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



 
Reply With Quote
 
Chris Theis
Guest
Posts: n/a
 
      07-02-2003

"christos panagiotou" <(E-Mail Removed)> wrote in message
news:bdtfov$d74$(E-Mail Removed)...
> 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


 
Reply With Quote
 
Xavier Decoret
Guest
Posts: n/a
 
      07-02-2003


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: http://www.velocityreviews.com/forums/(E-Mail Removed) |
| home : http://www.graphics.lcs.mit.edu/~decoret|
+-------------------------------------------------+

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiler Error Message: The compiler failed with error code -1073741819 Ram ASP .Net 0 09-13-2005 09:52 AM
Why is a JIT compiler faster than a byte-compiler RickMuller Python 4 03-26-2005 04:30 PM
Compiler compiler with C++ as output Andrey Batyuck C++ 3 05-17-2004 08:17 PM
Can we use <compiler> tag to avoid RunTime Compiler error? Jack Wright ASP .Net 5 01-19-2004 04:36 PM
Compiler Error Message: The compiler failed with error code 128. Yan ASP .Net 0 07-21-2003 10:49 PM



Advertisments