compiler error

Discussion in 'C++' started by christos panagiotou, Jul 2, 2003.

  1. 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
    christos panagiotou, Jul 2, 2003
    #1
    1. Advertising

  2. "christos panagiotou" <> 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
    Victor Bazarov, Jul 2, 2003
    #2
    1. Advertising

  3. christos panagiotou

    David White Guest

    christos panagiotou <> wrote in message
    news:bdtfov$d74$...
    > 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
    David White, Jul 2, 2003
    #3
  4. christos panagiotou

    Chris Theis Guest

    "christos panagiotou" <> wrote in message
    news:bdtfov$d74$...
    > 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
    Chris Theis, Jul 2, 2003
    #4
  5. 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|
    +-------------------------------------------------+
    Xavier Decoret, Jul 2, 2003
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yan
    Replies:
    0
    Views:
    1,115
  2. Jack Wright
    Replies:
    5
    Views:
    611
    Shiv Kumar
    Jan 19, 2004
  3. Ram
    Replies:
    0
    Views:
    2,816
  4. Andrey Batyuck

    Compiler compiler with C++ as output

    Andrey Batyuck, May 11, 2004, in forum: C++
    Replies:
    3
    Views:
    429
    Frederik Hertzum
    May 17, 2004
  5. RickMuller
    Replies:
    4
    Views:
    692
    Alexey Shamrin
    Mar 26, 2005
Loading...

Share This Page