Build the plugin with third lib in mac m1(macOS-arm64) failed

develop env:
ue version 5.0.2
mac2021 m1
ide: rider

I build the plugin with third lib(libkafka++.dylib which install by brewing in macOs) failed. the log below:

ld: warning: ignoring file
XXX/Mac/Release/librdkafka++.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture x86_64:

Did You find a solution?
Im receiving the same problem.

1 Like

I’d very much like to find a solution for this too

I met this problem and find some solution for it.

In short:

You can generate a third party plugin project on windows (which I did) or Mac intel(might work), as I generated a plugin called “TestPlugin”.(Of course you can copy a project from others). Then comment out code(or delete) :


StartupModule();

ShutdownModule();

in TestPlugin.cpp (you should find it on your xxxx.cpp)

And write your own code now and run it without any problem.

The reason is, in the original code of unreal engine, the template of third party has a part called xxxxLibrary(In my project, it is TestPluginLibrary) in the template file ThirdParty. If you open the build.cs of it, you will find code:


else if (Target.Platform == UnrealTargetPlatform.Mac)

{

PublicDelayLoadDLLs.Add(Path.Combine(ModuleDirectory, "Mac", "Release", "libExampleLibrary.dylib"));

RuntimeDependencies.Add("$(PluginDir)/Source/ThirdParty/TestPluginLibrary/Mac/Release/libExampleLibrary.dylib");

}

Unfortunately, this dylib was only built for x64 and might don’t work for arm64), which is the architecture of Mac apple silicon.

And you can treat the xxxx.cpp as the main.cpp of the template. (As I have a try to build manually and zsh told me some info, but I’m not sure it’s the main reason, below is the theory if it is).

Those two function: StartupModule() and ShutdownModule() use TestPluginLibrary, which I think is the 3rd party example model written by UE. But they forget to make a dylib for arm64(so I think linux by arm64 might has this problem either), even if we use a generated project by other platform, we can’t build or run it on Mac apple silicon directly. So if comment it or delete them, you can build your own plugin which is without any function (And in xxxxLibrary, it only have function “printf("Loaded ExampleLibrary from Third Party Plugin sample”);”, which it’s no need).

In a word, this is only a template that UE use it to teach how to write a 3rd plugin, you can build an empty plugin and write your own too. Or copy the necessary code from a generated 3rd plugin and write your own function.

And for epic, I hope they can fix this short of resource problem(if the reason is it), the Mac apple silicon won’t wish to change their platform to generate a code then turn back as they meet this problem.