Dev C++ Undefined Refrence

Hello, i got the same problem, the reason was because i had another mingw instalations in my system. It seems that devc looks for a mingw installation each time it starts. The solution: i rename the c:mingw folder and everything start working. Jun 14, 2011  I am using Dev-cpp - 7.3.1.3 On Windows XP. I want to use curl in my project built using devcpp. So I created a static library (project) in devcpp for the same. I have include all the necessary curl files in it. Then i created a console project, But i have no idea as to how to link to my static library. While running the following code. Mar 06, 2016  There's a FAQ here that tells you how to implement your own 'gotoxy' in Windows: gotoxy and textcolor - error: undefined reference And other that gives you alternatives to color your text in Windows (see the second bit of code): FAQ Color my text - Cprogramming.com. By including the header in your main file, the compiler is informed of the description of class Hash when compiling the file, but not how class Hash actually works. When the linker tries to create the entire program, it then complains that the implementation (toHash::insert(int, char)) cannot be found.

I thought I was finished with my code until I tried to compile it and came out with an error that I really don't know where it's coming from. Can anyone look over and see if they can find the source of the error?
Please and thank you!

These are the errors I'm getting:

Dev C++ Undefined Reference To __imp_wsastartup'

/cygdrive/c/Users/Shelby Jr/workspace/Program5/Debug/../file_filter.cpp:10: undefined reference to Dynque<char>::Dynque()' makefile:44: recipe for targetProgram5.exe' failed
/cygdrive/c/Users/Shelby Jr/workspace/Program5/Debug/../file_filter.cpp:18: undefined reference to Dynque<char>::enqueue(char)' /cygdrive/c/Users/Shelby Jr/workspace/Program5/Debug/../file_filter.cpp:25: undefined reference toDynque<char>::dequeue(char&)'
/cygdrive/c/Users/Shelby Jr/workspace/Program5/Debug/../file_filter.cpp:28: undefined reference to Dynque<char>::isEmpty()' /cygdrive/c/Users/Shelby Jr/workspace/Program5/Debug/../file_filter.cpp:31: undefined reference toDynque<char>::~Dynque()'
/cygdrive/c/Users/Shelby Jr/workspace/Program5/Debug/../file_filter.cpp:31: undefined reference to `Dynque<char>::~Dynque()'

Dynqueue.h

Dynqueue.cpp

Edited by TexasJr
  • 2 Contributors
  • forum 2 Replies
  • 1,381 Views
  • 10 Hours Discussion Span
  • commentLatest Postby TexasJrLatest Post

sepp2k378

When defining template functions or member functions of template classes, you can't put the definitions in a separate file from the declaration. Both the declaration and the definition need to be visible to the code that uses your functions. So you need to put the contents of Dynqueue.cpp into Dynqueue.h instead.

Undefined Reference To Clrscr+dev-c++

And yes, that's the complete opposite of what you're usually supposed to do, but that's how it is.

Edited by sepp2k

I'm self studying from the book, C++ Primer Plus Fifth Edition, by Stephen Prata. The following relates to Chapter 13, Page 699, Programming Exercise #4. One task is to write the derived class method definitions based upon the given prototypes. The following are the said prototypes.

You will note that the base class destructor is virtual. That the derived class destructor is implemented inline.

I was creating the derived class method definitions in a cpp file and couldn't get the project to progressively compile correctly. At my first method definition, a default constructor, the compiler kept spitting out this error message:

Chapter-13pe-13-04port.cpp 74 undefined reference to `vtable for VintagePort'

The line number was pointing to my derived class constructor definition. I did some googling around and came across this workaround. I removed the inline effect of the derived class destructor, made that into a method definition in the cpp file and presto, compilation succeeded.

Am I to assume that the example in the book, as regards the inline feature of a derived class destructor, is in error. Are there any other explanations.

  • 10 Contributors
  • forum 10 Replies
  • 28,035 Views
  • 2 Years Discussion Span
  • commentLatest Postby sheldonrobinsonLatest Post

Recommended Answers

I was creating the derived class method definitions in a cpp file
and couldn't get the project to progressively compile correctly.
At my first method definition, a default constructor,
the compiler kept spitting out this error message:

this is perhaps the most obscure error message that gcc (actually …

Jump to Post

All 10 Replies

vijayan1211,152

> I was creating the derived class method definitions in a cpp file
> and couldn't get the project to progressively compile correctly.
> At my first method definition, a default constructor,
> the compiler kept spitting out this error message:

this is perhaps the most obscure error message that gcc (actually the linker) spits out, but the reason is simple:

the compiler has to put the (one and only one) vtable for a class into some object file or the other. it puts it into the object file for the translation unit where the definition of the first non-pure-virtual out-of-line virtual member function is present. if there is no such definition, you get this rather unhelpful linker error message.

you would be able to progressively compile the code even if a non-pure virtual function is not defined, but to be able to link without errors, every such function must have a definition (at least a stub). and to prevent the non-creation of a v-table by the compiler, at least one of the non-pure virtual functions will have to be defined out-of-line.

gcc has a faq about this: http://gcc.gnu.org/faq.html#vtables

Dev C++ Undefined Reference Page


> Am I to assume that the example in the book, as regards the inline feature
> of a derived class destructor, is in error.
i think it is not a particularly good book, but in this case neither the book nor the compiler is in error.
if you define the destructor inline, and void VintagePort::Show() const out-of-line, the error will go away. there has to be at least one out-of-line definition of a non-pure-virtual function.

note: the microsoft compiler (as well as several other compilers) does not require this; it instantiates a v-table with internal linkage in *every* translation unit in which such a header (all non-pure virtual functions are inline) is included. this violates the c++ one definition rule for v-tables, but as always, folks at redmond tend to value pragmatism highly. and they do give you __declspec(novtable) to suppress the proliferation of v-tables.

Dev C++ Undefined Reference

superjacent commented: To the point and relevant advice, thank you.+1