Linker error: undefined reference to `___builtin_vec_new'

Discussion in 'C++' started by Ed Dana, Jan 8, 2008.

  1. Ed Dana

    Ed Dana Guest

    I'm trying to create a dynamic two dimensional array. My code looks like
    this:
    ======================================================================
    #define DEF_FrameBuffer_H

    class FrameBuffer {
    public:
    FrameBuffer(int prmWidth, int prmHeight, unsigned long prmPen);
    FrameBuffer(int prmWidth, int prmHeight);

    private:
    int clsHeight, clsWidth, clsCurrX, clsCurrY;
    unsigned long **clsBuffer, clsPen;
    };
    ======================================================================
    #include <cstdlib>
    #include <iostream>

    #include <string>

    // Declarations...
    #ifndef DEF_FrameBuffer_H
    #include "FrameBuffer.h"
    #endif

    // Constructors...
    FrameBuffer::FrameBuffer( int prmWidth,
    int prmHeight,
    unsigned long prmPen
    ) {
    int x, y;

    clsWidth = prmWidth;
    clsHeight = prmHeight;

    clsBuffer = new unsigned long *[prmWidth];
    if (clsBuffer) {
    for (x = 0; x < prmHeight; x++) {
    clsBuffer[x] = new unsigned long [prmHeight];
    clsBuffer[x][y] = prmPen;
    }
    }
    }

    FrameBuffer::FrameBuffer(int prmWidth, int prmHeight) {
    FrameBuffer::FrameBuffer(prmWidth, prmHeight, 0);
    }
    ======================================================================

    The program compiles fine, but the linker gives me the error: [Linker
    error] undefined reference to `___builtin_vec_new'

    I have no clue what this means except I suspect it has something to do
    with the "new" keyword. As far as I can tell, this should work. This is
    being compiled using Bloodshed's Dev-C++.

    Any and all clues greatly appreciated.

    Ed.
     
    Ed Dana, Jan 8, 2008
    #1
    1. Advertising

  2. Ed Dana

    Ed Dana Guest

    OK, I just compiled this in Visual C++ and it compiled fine. It must be
    a compiler problem, so I'm taking it over to the Bloodshed C++ forum.
    Still, any clues are still welcome for any who are willing to help. :)


    Ed Dana wrote:
    > I'm trying to create a dynamic two dimensional array. My code looks like
    > this:
    > ======================================================================
    > #define DEF_FrameBuffer_H
    >
    > class FrameBuffer {
    > public:
    > FrameBuffer(int prmWidth, int prmHeight, unsigned long prmPen);
    > FrameBuffer(int prmWidth, int prmHeight);
    >
    > private:
    > int clsHeight, clsWidth, clsCurrX, clsCurrY;
    > unsigned long **clsBuffer, clsPen;
    > };
    > ======================================================================
     
    Ed Dana, Jan 8, 2008
    #2
    1. Advertising

  3. Ed Dana

    Lars Uffmann Guest

    Ed Dana wrote:
    > OK, I just compiled this in Visual C++ and it compiled fine. It must be
    > a compiler problem, so I'm taking it over to the Bloodshed C++ forum.
    > Still, any clues are still welcome for any who are willing to help. :)


    Undefined references usually mean that you included a header file
    correctly (thus the compiler doesn't complain) but have to supply the
    according library for the linker, so the precompiled function code can
    be linked into your final executable. It should be solvable with the
    correct -lLIBRARY option and maybe -LPATHTOLIBRARY for the linker.

    Best Regards,

    Lars
     
    Lars Uffmann, Jan 9, 2008
    #3
  4. Ed Dana

    James Kanze Guest

    On Jan 8, 11:27 pm, Ed Dana <> wrote:
    > OK, I just compiled this in Visual C++ and it compiled fine.
    > It must be a compiler problem, so I'm taking it over to the
    > Bloodshed C++ forum. Still, any clues are still welcome for
    > any who are willing to help. :)


    It's probably one of two things: your compiler is not installed
    correctly, or for some reason, it is trying to link the code as
    if it were C and not C++ (and thus not picking up the run-time
    support for C++). (G++ will do this if you compile and link
    with the command gcc: gcc is the basic compiler driver, which
    doesn't really know about C++ -- it will invoke the correct
    compiler, according to the source file suffix, but it will only
    append the minimum libraries for C, typically libc.a on a Unix
    system when linking. Invoking g++ will ensure that the C++
    runtime support is linked in as well.)

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Jan 9, 2008
    #4
  5. Ed Dana

    James Kanze Guest

    On Jan 9, 10:34 am, Lars Uffmann <> wrote:
    > Ed Dana wrote:
    > > OK, I just compiled this in Visual C++ and it compiled fine.
    > > It must be a compiler problem, so I'm taking it over to the
    > > Bloodshed C++ forum. Still, any clues are still welcome for
    > > any who are willing to help. :)


    > Undefined references usually mean that you included a header
    > file correctly (thus the compiler doesn't complain) but have
    > to supply the according library for the linker, so the
    > precompiled function code can be linked into your final
    > executable. It should be solvable with the correct -lLIBRARY
    > option and maybe -LPATHTOLIBRARY for the linker.


    The symbol he was missing was __builtin_vec_new. A symbol
    starting with two underscores does not come from a user defined
    library (hopefully, at least), but from the runtime support of
    C++. The library with the necessary runtime support should be
    pulled in automatically, *if* he uses a compiler driver to
    invoke the link, that compiler driver is C++ aware, and knows
    (or supposes) that the code being linked is C++.

    (Note that the command we usually use to invoke the
    "compiler"---cl, CC or g++ on my systems---really invokes a
    compiler driver---a small program which invokes the actual
    compiler, but also the linker, and in some cases the library
    manager. And that while cl seems to be the only compiler driver
    for VC++, and always supposes C++, cc and gcc exist along side
    of CC and g++, and will not link in the C++ runtime support when
    they invoke the linker.)

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Jan 9, 2008
    #5
  6. Ed Dana

    Lars Uffmann Guest

    James Kanze wrote:
    > The symbol he was missing was __builtin_vec_new. A symbol
    > starting with two underscores does not come from a user defined
    > library (hopefully, at least), but from the runtime support of
    > C++. The library with the necessary runtime support should be
    > pulled in automatically, *if* he uses a compiler driver to
    > invoke the link, that compiler driver is C++ aware, and knows
    > (or supposes) that the code being linked is C++.


    Hmm - I guess I should keep my mouth shut and focus on my real strengths
    - developing solutions rather than spread my very limited knowledge
    about compiler and linker issues *g*

    Didn't know the underscore-convention. Thanks for clearing that up.
     
    Lars Uffmann, Jan 9, 2008
    #6
  7. Ed Dana

    Ed Dana Guest

    Reinstalling didn't work. However, your info got me to thinking... my
    little experiment started as a C program, and then I switched it over to
    C++. DevC++ allows me to change individual files between C and C++ but I
    didn't see where I could do that at the project level. Creating a new
    project as C++ and adding the original files back in fixed the problem.

    Thanks for the clues! I needed them. ;)

    Ed.


    James Kanze wrote:
    > On Jan 8, 11:27 pm, Ed Dana <> wrote:
    >> OK, I just compiled this in Visual C++ and it compiled fine.
    >> It must be a compiler problem, so I'm taking it over to the
    >> Bloodshed C++ forum. Still, any clues are still welcome for
    >> any who are willing to help. :)

    >
    > It's probably one of two things: your compiler is not installed
    > correctly, or for some reason, it is trying to link the code as
    > if it were C and not C++ (and thus not picking up the run-time
    > support for C++). (G++ will do this if you compile and link
    > with the command gcc: gcc is the basic compiler driver, which
    > doesn't really know about C++ -- it will invoke the correct
    > compiler, according to the source file suffix, but it will only
    > append the minimum libraries for C, typically libc.a on a Unix
    > system when linking. Invoking g++ will ensure that the C++
    > runtime support is linked in as well.)
    >
    > --
    > James Kanze (GABI Software) email:
    > Conseils en informatique orientée objet/
    > Beratung in objektorientierter Datenverarbeitung
    > 9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    Ed Dana, Jan 9, 2008
    #7
    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. Replies:
    1
    Views:
    664
    Jules
    Aug 18, 2005
  2. Replies:
    4
    Views:
    1,646
    Peter Jansson
    Dec 16, 2005
  3. Mark
    Replies:
    4
    Views:
    6,153
    Githlar
    Mar 13, 2006
  4. Oliver Bleckmann
    Replies:
    1
    Views:
    520
    Rud1ger Sch1erz
    Nov 30, 2006
  5. Replies:
    3
    Views:
    598
Loading...

Share This Page