Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Inherit from another projects class(Inherit from another projects class)
Inherit from another projects class [message #1703776] Tue, 04 August 2015 20:41 Go to next message
Mett Matt is currently offline Mett MattFriend
Messages: 2
Registered: August 2015
Junior Member
Hello together,
I am new to Eclipse-CDT and I have the following Problem:
I have 2 C++-Projects im my Workspace,
now i want ClassB in Project 2 to inherite from ClassA in Project 1
I managed that by adding the Source-Path of Project 1 to the Include-List (Project2->Properties->Paths and Symbols->Include) of Project2
After that I am able to include the header for ClassA in my ClassB-Source.
But when i want to build Project2 i got the following Errors:

Quote:

Nicht definierter Verweis auf `ClassA::ClassA(char*)' ClassB.cpp /Project2/src/system line 16 C/C++ Problem
Nicht definierter Verweis auf `ClassA::~ClassA()' ClassB.cpp /Project2/src/system line 21 C/C++ Problem



Line 16 is the Call of the ClassB-Constructor,
Line 21 is the ClassB-Destructor:


ClassA - Header:
class ClassA
{
protected:

public:
	ClassA(char *workingDir);
	virtual ~ClassA();
};



ClassA - cpp:
ClassA::ClassA(char *workingDir)
{
}


ClassA::~ClassA()
{
}



ClassB - Header:
class ClassB : public ClassA
{
public:
	ClassB(char *workingDir);
	virtual ~ClassB();
};



ClassB - cpp:
ClassB::ClassB(char *workingDir) :
ClassA(workingDir) // Line 16 -> Nicht definierter Verweis auf `ClassA::ClassA(char*)'	ClassB.cpp	/Project2/src/system	line 16	C/C++ Problem
{

}

ClassB::~ClassB() // Line21 -> Nicht definierter Verweis auf `ClassA::~ClassA()'	ClassB.cpp	/Project2/src/system	line 21	C/C++ Problem
{
}



What is the Problem here?
Re: Inherit from another projects class [message #1703906 is a reply to message #1703776] Wed, 05 August 2015 18:22 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Undefined reference (Nicht definierter Verweis) is a linker error. It means the linker couldn't find the object files defining ClassA members. If these are in a different project then you need a way to cause the linker to include the objects files from the project containing ClassA when linking executables using ClassB.

I realize this is vague but you apparently have code missing in your post. For example, how does ClassB know about ClassA in your ClassB - Header and ClassB - cpp and is there a main routine somewhere? Also, are these managed projects or makefile projects? It's difficult to know ahead of time what would be helpful, ain't it? Razz

I tend to think of related projects as libraries for use by the project intended to produce main executable code. That means the "external" projects should be building link libraries. Perhaps the easiest way is to combine all of them into one project unless there is some pressing reason for keeping them separate.


Re: Inherit from another projects class [message #1703914 is a reply to message #1703906] Wed, 05 August 2015 19:42 Go to previous message
Mett Matt is currently offline Mett MattFriend
Messages: 2
Registered: August 2015
Junior Member
Thank you for Your Answer.
Meanwhile I solved the Problem (missing *.o files) like described in this Post: https://www.eclipse.org/forums/index.php?t=msg&th=210738&goto=685743&#msg_685743
Previous Topic:[SOLVED] gtkmm & eclipse on ubuntu
Next Topic:Hello World debug works, run fails
Goto Forum:
  


Current Time: Fri Apr 19 23:00:50 GMT 2024

Powered by FUDForum. Page generated in 0.02879 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top