[UE4]windows和android调用第三方C++库(静态库lib、动态库dll)

 官方wiki

C++调用静态库StaticLibrary(lib)

Linking Static Libraries

https://wiki.unrealengine.com/Linking_Static_Libraries_Using_The_Build_System

 

C++调用动静态链接库Dynamic Link Library(dll)

Linking Dlls

https://wiki.unrealengine.com/Linking_Dlls

 

再给一个Android版本添加静态库的例子,参考Photon SDK(在“工程.Build.cs”中添加),其实linux、windows也都是这么添加的,区别就是引用的文件不一样,windows是dll和lib,linux是.so和.a(linux上的so和a文件和android上的so和a文件是两码事,android上的so和a必须通过NDK编译获得):

private string PhotonPath
{
    get { return Path.GetFullPath(Path.Combine(ModulePath, "..", "Photon")); }
}
//
if ( Target.Platform == UnrealTargetPlatform.Android)
{
    // Set _EG_WINDOWS_PLATFORM for Windows, _EG_IPHONE_PLATFORM for iOS and _EG_IMAC_PLATFORM for OS X
    Definitions.Add("_EG_ANDROID_PLATFORM");
    //
    PublicAdditionalLibraries.Add(Path.Combine(PhotonPath, "lib", "Android", "libcommon-cpp-static_debug_android_armeabi_no-rtti.a"));
    PublicAdditionalLibraries.Add(Path.Combine(PhotonPath, "lib", "Android", "libphoton-cpp-static_debug_android_armeabi_no-rtti.a"));
    PublicAdditionalLibraries.Add(Path.Combine(PhotonPath, "lib", "Android", "libloadbalancing-cpp-static_debug_android_armeabi_no-rtti.a"));
}

 

 

 

论坛参考

Link to 3rd Party Libraries

https://answers.unrealengine.com/questions/76792/link-to-3rd-party-libraries.html

How do I add thirdparty library?

https://answers.unrealengine.com/questions/218616/how-do-i-add-thirdparty-library.html

How do you statically link an external DLL/dylib to your project?

https://answers.unrealengine.com/questions/197667/how-do-you-statically-link-an-external-dlldylib-to.html

 

你可能感兴趣的:(UnrealEngine)