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

Can't build Unreal Engine plugin on Linux/Mac because of unsupported typeid keyword #870

Closed
1 of 3 tasks
demonixis opened this issue Mar 28, 2023 · 5 comments
Closed
1 of 3 tasks

Comments

@demonixis
Copy link
Contributor

demonixis commented Mar 28, 2023

I'm submitting a ...

  • bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.

Describe the issue
The Unreal Engine plugin can't be compiled on Linux after adapting the JSBSim.build.cs because of error.

What is the current behavior?
Here is the error log

Building 6 actions with 6 processes...
[1/6] Compile Module.JSBSimFlightDynamicsModel.cpp
In file included from /home/yann/Projects/jsbsim/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/JSBSimFlightDynamicsModel/Module.JSBSimFlightDynamicsModel.cpp:6:
In file included from /home/yann/Projects/jsbsim/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/JSBSimFlightDynamicsModel/Private/JSBSimMovementComponent.cpp:16:
In file included from /home/yann/Projects/jsbsim/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include/FGFDMExec.h:46:
In file included from /home/yann/Projects/jsbsim/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include/models/FGPropagate.h:43:
In file included from /home/yann/Projects/jsbsim/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include/models/FGModel.h:44:
In file included from /home/yann/Projects/jsbsim/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include/math/FGModelFunctions.h:40:
In file included from /home/yann/Projects/jsbsim/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include/input_output/FGPropertyReader.h:43:
/home/yann/Projects/jsbsim/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include/simgear/props/props.hxx:1895:14: error: use of typeid requires -frtti
      return typeid(T).name();
             ^
5 errors generated.
[2/6] Link (lld) libUnrealEditor-JSBSimFlightDynamicsModel.so cancelled
[3/6] Link (lld) libUnrealEditor-UEReferenceApp.so cancelled
[4/6] Compile Module.JSBSimFlightDynamicsModelEditor.cpp
In file included from /home/yann/Projects/jsbsim/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/JSBSimFlightDynamicsModelEditor/Module.JSBSimFlightDynamicsModelEditor.cpp:3:
In file included from /home/yann/Projects/jsbsim/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/JSBSimFlightDynamicsModelEditor/Private/JSBSimMovementCompVisualizer.cpp:14:
In file included from /home/yann/Projects/jsbsim/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include/models/FGLGear.h:43:
In file included from /home/yann/Projects/jsbsim/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include/models/propulsion/FGForce.h:62:
In file included from /home/yann/Projects/jsbsim/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include/models/FGMassBalance.h:43:
In file included from /home/yann/Projects/jsbsim/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include/models/FGModel.h:44:
In file included from /home/yann/Projects/jsbsim/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include/math/FGModelFunctions.h:40:
In file included from /home/yann/Projects/jsbsim/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include/input_output/FGPropertyReader.h:43:
/home/yann/Projects/jsbsim/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include/simgear/props/props.hxx:1895:14: error: use of typeid requires -frtti
      return typeid(T).name();
             ^
1 error generated.
[5/6] Link (lld) libUnrealEditor-JSBSimFlightDynamicsModelEditor.so cancelled
[6/6] WriteMetadata UEReferenceAppEditor.target cancelled

What is the expected behavior?
The expected behaviour is to have the plugin compiling on Linux

What is the motivation / use case for changing the behavior?
Using JSBSim for Unreal on the Linux operating system

Please tell us about your environment:

  • OS Ubuntu 23.04 and Macos 12
  • JSBSim version (Latest)

You can follow my work on my fork

@demonixis
Copy link
Contributor Author

demonixis commented Mar 29, 2023

I fixed many problems on my branch now the problem is about the typeid keyword that breaks the compilation on Linux and Mac. It's not possible to easilly add rtti without rebuilding the game engine itself.
A quick fix to validate that the plugin can compile on mac/linux is to hack the prop.hxx file like this

static const char* name() { return ""; }// typeid(T).name(); }

But it's not good... So I'm asking for help to find a way to replace typeid OR make it work with Unreal.

@demonixis demonixis changed the title Can't build Unreal Engine plugin on Linux Can't build Unreal Engine plugin on Linux/Mac because if unsupported typeid keyword Mar 29, 2023
@seanmcleod
Copy link
Member

So are you saying that the Unreal engine on Windows is built with rtti enabled but not by default on Mac and Linux?

@demonixis
Copy link
Contributor Author

Well I'm not sure but it doesn't compile on Linux and macOS. However with the "hack" it compiles fine... I was able to run launch the Unreal project on macOS and I'll try on Linux too later today.

I suppose that there is no easy workaround and returning an empty string is not a good solution right?

Capture d’écran 2023-03-29 à 18 14 36

JSBSim Unreal on macOS ;)

@demonixis demonixis changed the title Can't build Unreal Engine plugin on Linux/Mac because if unsupported typeid keyword Can't build Unreal Engine plugin on Linux/Mac because of unsupported typeid keyword Mar 29, 2023
@bcoconni
Copy link
Member

@demonixis, actually you can safely delete the code lines 1881-1929 in src/simgear/props/props.hxx, these are unused by JSBSim.

namespace simgear
{
/**
* Default trait for extracting enum values from SGPropertyNode. Create your
* own specialization for specific enum types to enable validation of values.
*/
template<class T>
struct enum_traits
{
/**
* Typename of the enum
*/
static const char* name() { return typeid(T).name(); }
/**
* @return Default value (will be used if validation fails)
*/
static T defVal() { return T(); }
/**
* @return Whether the given integer value has an enum value defined
*/
static bool validate(int) { return true; }
};
} // namespace simgear
/** Extract enum from SGPropertyNode */
template<typename T>
#if PROPS_STANDALONE
inline T
#else
inline typename boost::enable_if<boost::is_enum<T>, T>::type
#endif
getValue(const SGPropertyNode* node)
{
typedef simgear::enum_traits<T> Traits;
int val = node->getIntValue();
if( !Traits::validate(val) )
{
SG_LOG
(
SG_GENERAL,
SG_WARN,
"Invalid value for enum (" << Traits::name() << ", val = " << val << ")"
);
return Traits::defVal();
}
return static_cast<T>(node->getIntValue());
}

Once you're happy with your code (including deleting the lines mentioned above), you can submit a PR.

@demonixis
Copy link
Contributor Author

In that case, I'll prepare a PR with macos support. Linux support is still on its way because I've some error with the linking process. It's related to Unreal and not JSBSim. I don't know why, but linking the static lib on macos works well. On Linux, the static or dynamic cause linking issue. I've to investigate.

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

No branches or pull requests

3 participants