Ok, I am very new in C++ development. This question may be silly but I can not find its response in any tutorial, book, question/response. It would be great if somebody can kindly explain it to me.
I have 1 header-source pair inside of a shared library libdummy.so:
This is dummy.h:
class dummy
{
public:
~dummy();
dummy();
bool dosomething(int a);
};
and this is dummy.cpp:
#include "dummy.h"
dummy::dummy()
{
//some assignments here
clear();
}
dummy::~dummy()
{
clear();
}
bool dummy::dosomething(int a)
{
// do something here
return true;
}
EDIT: I tell you above the sample codes of dummy.h and dummy.cpp but these files are not in my hand. They are packed inside the library libdummy.so. I have only the libdummy.so shared library file in the hand.
And I have a client to access my shared library.
client.h is here:
#include "dummy.h"
class client
{
public:
void myownjob();
dummy thingy;
//and some functions here
};
and finally this is the client.cpp:
#include "client.h"
void client::myownjob()
{
thingy.dosomething(1);
}
Now my problem is; when I try to compile this code, I get undefined reference errors to the constructor and destructor:
error: undefined reference to 'dummy::~dummy()'
error: undefined reference to 'dummy::dosomething(int)'
error: undefined reference to 'dummy::dummy()'
EDIT: The dummy.h and dummy.cpp are inside libdummy.so. I have only 3 files in the hand: libdummy.so, client.h and client.cpp.
That's why;
I can not delete ~dummy(); and dummy(); in the dummy.h to let the compiler creating them automatically. Because dummy.h is inside the libdummy.so shared library. It is not directly editable.
I can not do some braceleted empty definitions like ~dummy(){} and dummy(){} in the dummy.h. Because dummy.h is inside the libdummy.so shared library. It is not directly editable.
I can not include dummy.cpp to SRC_FILES line of my makefile. Because dummy.cpp is inside libdummy.so shared library. It is not a seperate file.
I think this is a very simple/beginner problem, but I can not find its response anywhere. What I have to do to use a class which is inside a shared library, in C++, when I get undefined reference errors to the constructors and destructors?
Thanks in advance.