Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: undefined reference to typeinfo #5

Open
SailingDreams opened this issue Jul 23, 2020 · 6 comments
Open

error: undefined reference to typeinfo #5

SailingDreams opened this issue Jul 23, 2020 · 6 comments

Comments

@SailingDreams
Copy link

SailingDreams commented Jul 23, 2020

FYI
I got a linker error when trying to build a android library using another library that has the TrimWright .h and .cpp in it.
The error is:
out/target/product/myExperiment/obj_arm/SHARED_LIBRARIES/libneorender_intermediates/src/UsRenderer.o:UsRenderer.cpp:typeinfo for gfx::UsRenderer: error: undefined reference to 'typeinfo for StateMachineTrimWright::FSM'

The error was resolved by making the function below non virtual (it doesn't make sense to me why this would be a linker issue).

// This dispatches an event to the current state.
// It doesn't generally need to be overridden by child classes.
//virtual void dispatch(const Event* event);
void dispatch(const Event* event);
@drewfish
Copy link
Owner

Thanks for the report. I'm not super-strong on C++ so this is curious to me too. What compiler (and version) are you using?

Since inheritance is used so lightly, if no other solution turns up I can always add a #define to conditionally adjust things.

@drewfish
Copy link
Owner

Oh hmm... this gives a clue:
https://stackoverflow.com/questions/307352/g-undefined-reference-to-typeinfo#307427
This seems to suggest that whatever build environment you have is not also compiling and linking TrimWright.cpp.

@SailingDreams
Copy link
Author

I am building the Android Tree
I had looked at the link you mentioned and that gave a clue what it was due to a virtual function. By piecemeal adding the SM parts to my code, I figured out that it was the virtual declaration of the dispatch function.

@drewfish
Copy link
Owner

Hmm... the fact that you fixed it by commenting out the virtual suggests that your environment is probably compling and linking TrimWright.cpp. That same stackoverflow page mentions a few other causes (I should have kept reading). This makes me think that there might be value in dropping the inheritance (HSM no longer inherting from FSM), at least as a #define guarded option.

@drewfish
Copy link
Owner

I've created PR #6 which makes it so that HSM no longer inherits from FSM. Without that, lack of RTTI should hopefully not be an issue. Could you try it out?

@SailingDreams
Copy link
Author

Sure. Hopefully have it checked by Wednesday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants