Nov 05, 2017 For the Love of Physics - Walter Lewin - May 16, 2011 - Duration: 1:01:26. Lectures by Walter Lewin. They will make you ♥ Physics. Recommended for you. Here, we are going to learn why an Error: Id returned 1 exit status (undefined reference to 'main') occurs and how to fixed in C programming language? A humble request Our website is made possible by displaying online advertisements to our visitors. Apr 23, 2006 Not open for further replies. Which library does a Dev-C compiled program have to link with to resolve the following Linker error: when WinMain is clearly defined in the C source code as the name of main, using the Dev-C environment v4.9.9.2. And #include, i.e. Apr 09, 2015 Educated guess, how is 'DLLExport' defined? If it is a macro, did you define the right macro to get it defined correctly? Related question. Is the library providing the. So there is no place in memory where b actually resides (the reference is undefined). To deal with this, you have to manually declare it in a cpp file, with the syntax int A::b;. This way you are reserving some space for that variable.
- Dev C++ Undefined Reference Page
- Dev C++ Undefined Reference To
- Dev C++ Undefined Reference To Wsastartup@8'
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.
Dev C++ Undefined Reference Page
- 10 Contributors
- forum 10 Replies
- 28,039 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:
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 PostAll 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:
> 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
> 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.Dev C++ Undefined Reference To
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 To Wsastartup@8'
superjacent commented: To the point and relevant advice, thank you.+1