Hi Genodians,
I am attempting to extend the class Child (base/include/base/child.h) with an additional function. However, when compiling my test program, I receive an undefined references error, even though I added the implementation to src/lib/base/child.cc. My observation seems to be that the generated object file does not get linked into the executable but calling any other Child-related function works fine.
My child.h looks pretty much like this:
class Genode::Child : .... {
....
void test_print();
}
and in child.cc:
void Child::test_print() {
log(__PRETTY_FUNCTION__);
}
Is there anything I am overseeing? Thanks in advance!
Cheers, Simon
Hi Simon,
On 7/6/20 8:13 AM, Simon Himmelbauer wrote:
Hi Genodians,
I am attempting to extend the class Child (base/include/base/child.h) with an additional function. However, when compiling my test program, I receive an undefined references error, even though I added the implementation to src/lib/base/child.cc. My observation seems to be that the generated object file does not get linked into the executable but calling any other Child-related function works fine.
My child.h looks pretty much like this:
class Genode::Child : .... {
....
void test_print();
}
and in child.cc:
void Child::test_print() {
log(__PRETTY_FUNCTION__);
}
Is there anything I am overseeing? Thanks in advance!
In case you want to call 'Child::test_print()' from outside of the base library (e.g., a dynamically linked program), you need to add the mangled 'Child::test_print' symbol to the Genode base library symbol file [1]. This way the dynamic linker can find and export the function.
[1] repos/base/lib/symbols/ld
Regards,
Sebastian