【UE基础】UE4导入第三方库_4.25/4.26

对于所有第三方库都应该先加入对头文件目录的包含:

  在模块的Build.cs文件中,加入对应的第三方库的头文件包含路径: 

  • PublicIncludePaths.Add(path);//包含目录中的头文件并公开到外部模块

  • PrivateIncludePaths.Add(Path);//包含目录中的头文件并不公开到外部模块 

对于插件中的模块:

  PublicIncludePaths和PrivateIncludePaths可以接受特殊字符串开头的字符串: 

  • $(ModuleDir) 表示模块目录(D:\UE4_Project\testSlate\Plugins\MotionMocap\Source\MotionMocap)

  • $(PluginDir)  表示插件目录(D:\UE4_Project\testSlate\Plugins\MotionMocap)

  • $(EngineDir)  表示引擎目录(D:\Program Files (x86)\UE4\UE_4.22\Engine)

  • $(ProjectDir)  表示工程目录(D:\UE4_Project\testSlate) 

对于非插件中的模块:

  • PublicIncludePaths 和 PrivateIncludePaths 不接受特殊字符串。

  • 如果path是相对路径,则是从工程目录的  **Source开始D:\UE4_Project\testSlate\Source**  开始的相对路径。 

引入lib与dll(示例):

 

  lib: 

  • 包含库的搜索路径

  • 包含要使用的库

  • 特殊的,对于  .so  与  .a 文件可以不加后缀名  

PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "Libs","sqlite3.lib");
PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "Includes"));

  dll: 

  • 包含库同上

  • dll 文件需要复制到项目路径的 Binary 下,如果没有,模块会加载失败,使用 RuntimeDependencies.Add(TargetPath,path)  运行后会自动复制并添加依赖  

 String DllPath = Path.Combine(ModuleDirectory, "Binaries", "sqlite3.dll");
 RuntimeDependencies.Add(Path.Combine("$(ProjectDir)/Binaries/Win64/sqlite3.dll"), DllPath);
 //延迟加载
 PublicDelayLoadDLLs.Add("sqlite3.dll");

 RuntimeDependencies ,并不仅限于 dll ,也可以用于其他文件的操作,但path路径必须是以工程路径开始的,比如工程路径为D:\UE4_Project\testSlate\,则path必须是D:\UE4_Project\testSlate\包含的目录下的文件。
   path和sourcepath可接受以下特殊字符串:
  $(ModuleDir)
   表示模块目录(D:\UE4_Project\testSlate\Plugins\MotionMocap\Source\MotionMocap)
   $(PluginDir)
   表示插件目录,仅在插件模块中有效,游戏模块会报错(D:\UE4_Project\testSlate\Plugins\MotionMocap)
   $(EngineDir)
   表示引擎目录(D:\Program Files (x86)\UE4\UE_4.22\Engine)
   $(ProjectDir)
   表示工程目录(D:\UE4_Project\testSlate)
   $(TargetOutputDir)
   表示Directory containing the output executable,也就是exe文件输出目录,这个好像只在打包时有效。
   $(BinaryOutputDir)
   表示Directory containing the binary that links thismodule.也就是dll文件目录

  Android 

 

  • 需要导入xml文件和Launch模块,然后再xml文件中复制和引入包

  • [详情参考](https://zhuanlan.zhihu.com/p/34374244  

if(Target.Platform == UnrealTargetPlatform.Android)
{
    PrivateDependencyModuleNames.AddRange(new string[] { "Launch" });
    string PluginPath = Utils.MakePathRelativeTo(ModuleDirectory, Target.RelativeEnginePath);
    AdditionalPropertiesForReceipt.Add("AndroidPlugin", Path.Combine(PluginPath, "Compress_UPL.xml"));
}

  IOS 

 

  • 如图
else if (Target.Platform == UnrealTargetPlatform.IOS)
 {
     PublicAdditionalFrameworks.Add(
            new Framework(
                "Crasheye",        //name
                "IOS/Crasheye.embeddedframework.zip"       // path
            )
     );
}
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值