Is there a recommended c++ way to determine the platform and architecture at runtime in order to select the appropriate dynamic library to load?
Or to put it another way My plugin loads a dynamic library, I can conditionally compile a path for each platform no problem, but is there a similar selector to PLATFORM_LINUX that will tell me is it’s X86_64 or arm64?
Ideally I’d simply like to construct a path at runtime that uses the Platform name (which I can get with GetPlatformName) and architecture name, but I can’t see how to get the chip architecture at runtime.
Any advice? How typically do developers handle loading libraries at runtime for different platforms and architectures.
For 5.3 specifically I was able to use Target.Architecture inside the module’s Build.cs file. If you need it inside the .cpp/.h files. you can make certain macros using PublicDefinitions.Add("YOUR_DEFINE_ARHITECTURENAME"); and make #ifdef/#if conditions. If you have a different engine versions, you can still access the information in the module build file, but the type of variable is different.
if (Target.Architecture.ToLower().Contains("arm64"))
generates an error while building the solution (or in my case the Xcode project files):
error CS7036: There is no argument given that corresponds to the required formal parameter ‘destination’ of ‘MemoryExtensions.ToLower(ReadOnlySpan, Span, CultureInfo?)’
That doesn’t seem right me to me
Is this something you’ve seen, or know what the issue may be? Is this the variable type issue you referred to? I’m working with a source build of 5.3.2 on Mac arm64.
It certainly could be related. If you have the time, it would be best to take a look together and I can uncover that for you.
In my experience with Mac specifically multiple arhitectures could be valid at the same time during build time (because God knows why).
It would be best if we could take a look at this together because that format should work for 5.3. Is there an email/discord/twitter I can reach out to?