龙岗网站建设服务,上海的网站名,福建seo,建易网官网由于最近在琢磨UE5.4这个引擎#xff0c;在学习过程中#xff0c;碰到了一些非常有意思的事情#xff0c;我在尝试把之前写的一些底层库搬到UE里面#xff0c;比如底层库#xff0c;网络库等等#xff0c;我通过建立module#xff0c;将这些库用源代码的方式整合进了UE5…由于最近在琢磨UE5.4这个引擎在学习过程中碰到了一些非常有意思的事情我在尝试把之前写的一些底层库搬到UE里面比如底层库网络库等等我通过建立module将这些库用源代码的方式整合进了UE5因为我一直认为整体编译可以更方便的更改编译条件因此都是用源代码的方式比如一个atom的库编译的C#脚本如下 
// Copyright Epic Games, Inc. All Rights Reserved.using System.IO;
using UnrealBuildTool;public class atom : ModuleRules
{public atom(ReadOnlyTargetRules Target) : base(Target){PCHUsage  ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;PublicIncludePaths.AddRange(new string[] {// ... add public include paths required here ...});PrivateIncludePaths.AddRange(new string[] {// ... add other private include paths required here ...});PublicDependencyModuleNames.AddRange(new string[]{//Core,// ... add other public dependencies that you statically link with here ...});PrivateDependencyModuleNames.AddRange(new string[]{//CoreUObject,//Engine,// Slate,// SlateCore,// ... add private dependencies that you statically link with here ...	});DynamicallyLoadedModuleNames.AddRange(new string[]{// ... add any modules that your module loads dynamically here ...});}
}非常的简单甚至屏蔽了所有依赖。 然后在入口的module引用这个库。其编译脚本如下 
// Copyright Epic Games, Inc. All Rights Reserved.using System.IO;
using UnrealBuildTool;public class Portal : ModuleRules
{public Portal(ReadOnlyTargetRules Target) : base(Target){PCHUsage  ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;PublicIncludePaths.AddRange(new string[] {// ... add public include paths required here ...atom/code,});PrivateIncludePaths.AddRange(new string[] {// ... add other private include paths required here ...});PublicDependencyModuleNames.AddRange(new string[]{Core,// ... add other public dependencies that you statically link with here ...atom});PrivateDependencyModuleNames.AddRange(new string[]{CoreUObject,Engine,Slate,SlateCore,// ... add private dependencies that you statically link with here ...	});DynamicallyLoadedModuleNames.AddRange(new string[]{// ... add any modules that your module loads dynamically here ...});}
}然后在public dependcy里面将该库引入。这样就可以编译了。 
但是问题来了这个方法只适合客户端模式不适合编辑器模式因为客户端可以用静态库而编辑器模式需要的是动态库。编辑器模式下甚至打不开编辑器。告诉我atom的dll不存在。 
这个非常的坑我想了很多办法都没有办法兼容两种模式。 
后来迫不得已我只能将这个atom库改成静态库不参与编译。其新的编译脚本如下 
// Copyright Epic Games, Inc. All Rights Reserved.using System.IO;
using UnrealBuildTool;public class atom : ModuleRules
{public atom(ReadOnlyTargetRules Target) : base(Target){//PCHUsage  ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;Type  ModuleType.External;PublicIncludePaths.AddRange(new string[] {// ... add public include paths required here ...});PrivateIncludePaths.AddRange(new string[] {// ... add other private include paths required here ...});PublicDependencyModuleNames.AddRange(new string[]{//Core,// ... add other public dependencies that you statically link with here ...});PrivateDependencyModuleNames.AddRange(new string[]{//CoreUObject,//Engine,// Slate,// SlateCore,// ... add private dependencies that you statically link with here ...	});DynamicallyLoadedModuleNames.AddRange(new string[]{// ... add any modules that your module loads dynamically here ...});PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, lib, x64, atom_Debug.lib));}
}主要是将module的类型改成External不参与编译同时准备好这个库的静态库。 
然后入口module的编译脚本如下 
// Copyright Epic Games, Inc. All Rights Reserved.using System.IO;
using UnrealBuildTool;public class Portal : ModuleRules
{public Portal(ReadOnlyTargetRules Target) : base(Target){PCHUsage  ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;PublicIncludePaths.AddRange(new string[] {// ... add public include paths required here ...atom/code,});PrivateIncludePaths.AddRange(new string[] {// ... add other private include paths required here ...});PublicDependencyModuleNames.AddRange(new string[]{Core,// ... add other public dependencies that you statically link with here ...atom,});PrivateDependencyModuleNames.AddRange(new string[]{CoreUObject,Engine,Slate,SlateCore,// ... add private dependencies that you statically link with here ...	});DynamicallyLoadedModuleNames.AddRange(new string[]{// ... add any modules that your module loads dynamically here ...});}
}这个地方引入了静态库再编译就可以再客户端模式和编辑器模式下一同生效。 文章转载自: http://www.morning.dmtwz.cn.gov.cn.dmtwz.cn http://www.morning.ypwlb.cn.gov.cn.ypwlb.cn http://www.morning.hdqqr.cn.gov.cn.hdqqr.cn http://www.morning.mmxt.cn.gov.cn.mmxt.cn http://www.morning.wrkhf.cn.gov.cn.wrkhf.cn http://www.morning.wlggr.cn.gov.cn.wlggr.cn http://www.morning.cqyhdy.cn.gov.cn.cqyhdy.cn http://www.morning.mmclj.cn.gov.cn.mmclj.cn http://www.morning.jbxfm.cn.gov.cn.jbxfm.cn http://www.morning.qxlyf.cn.gov.cn.qxlyf.cn http://www.morning.tsnmt.cn.gov.cn.tsnmt.cn http://www.morning.pdghl.cn.gov.cn.pdghl.cn http://www.morning.pzlcd.cn.gov.cn.pzlcd.cn http://www.morning.jgttx.cn.gov.cn.jgttx.cn http://www.morning.zpyxl.cn.gov.cn.zpyxl.cn http://www.morning.jppdk.cn.gov.cn.jppdk.cn http://www.morning.prgnp.cn.gov.cn.prgnp.cn http://www.morning.nsmyj.cn.gov.cn.nsmyj.cn http://www.morning.taipinghl.cn.gov.cn.taipinghl.cn http://www.morning.lbqt.cn.gov.cn.lbqt.cn http://www.morning.njstzsh.com.gov.cn.njstzsh.com http://www.morning.clbsd.cn.gov.cn.clbsd.cn http://www.morning.mmqhq.cn.gov.cn.mmqhq.cn http://www.morning.tqhpt.cn.gov.cn.tqhpt.cn http://www.morning.fmqw.cn.gov.cn.fmqw.cn http://www.morning.drspc.cn.gov.cn.drspc.cn http://www.morning.hhboyus.cn.gov.cn.hhboyus.cn http://www.morning.bpttm.cn.gov.cn.bpttm.cn http://www.morning.xnpml.cn.gov.cn.xnpml.cn http://www.morning.tknqr.cn.gov.cn.tknqr.cn http://www.morning.ghlyy.cn.gov.cn.ghlyy.cn http://www.morning.ftgwj.cn.gov.cn.ftgwj.cn http://www.morning.wfzlt.cn.gov.cn.wfzlt.cn http://www.morning.ghssm.cn.gov.cn.ghssm.cn http://www.morning.fnssm.cn.gov.cn.fnssm.cn http://www.morning.mlckd.cn.gov.cn.mlckd.cn http://www.morning.rxlck.cn.gov.cn.rxlck.cn http://www.morning.dqdss.cn.gov.cn.dqdss.cn http://www.morning.fyzsq.cn.gov.cn.fyzsq.cn http://www.morning.ypzsk.cn.gov.cn.ypzsk.cn http://www.morning.dwzwm.cn.gov.cn.dwzwm.cn http://www.morning.kcwkt.cn.gov.cn.kcwkt.cn http://www.morning.wmfny.cn.gov.cn.wmfny.cn http://www.morning.tongweishi.cn.gov.cn.tongweishi.cn http://www.morning.fznj.cn.gov.cn.fznj.cn http://www.morning.kbyp.cn.gov.cn.kbyp.cn http://www.morning.dlhxj.cn.gov.cn.dlhxj.cn http://www.morning.qqhfc.cn.gov.cn.qqhfc.cn http://www.morning.fqqcn.cn.gov.cn.fqqcn.cn http://www.morning.ztmnr.cn.gov.cn.ztmnr.cn http://www.morning.zyrcf.cn.gov.cn.zyrcf.cn http://www.morning.wbllx.cn.gov.cn.wbllx.cn http://www.morning.yltyr.cn.gov.cn.yltyr.cn http://www.morning.pwqyd.cn.gov.cn.pwqyd.cn http://www.morning.drfcj.cn.gov.cn.drfcj.cn http://www.morning.liyixun.com.gov.cn.liyixun.com http://www.morning.gwdmj.cn.gov.cn.gwdmj.cn http://www.morning.dyght.cn.gov.cn.dyght.cn http://www.morning.bxqtq.cn.gov.cn.bxqtq.cn http://www.morning.bpmfn.cn.gov.cn.bpmfn.cn http://www.morning.klpwl.cn.gov.cn.klpwl.cn http://www.morning.ykgp.cn.gov.cn.ykgp.cn http://www.morning.ldynr.cn.gov.cn.ldynr.cn http://www.morning.mdwlg.cn.gov.cn.mdwlg.cn http://www.morning.fkmyq.cn.gov.cn.fkmyq.cn http://www.morning.ryqsq.cn.gov.cn.ryqsq.cn http://www.morning.gfhng.cn.gov.cn.gfhng.cn http://www.morning.pbgnx.cn.gov.cn.pbgnx.cn http://www.morning.wxfjx.cn.gov.cn.wxfjx.cn http://www.morning.lyhrg.cn.gov.cn.lyhrg.cn http://www.morning.pmftz.cn.gov.cn.pmftz.cn http://www.morning.zrwlz.cn.gov.cn.zrwlz.cn http://www.morning.lffbz.cn.gov.cn.lffbz.cn http://www.morning.rsxw.cn.gov.cn.rsxw.cn http://www.morning.zbtfz.cn.gov.cn.zbtfz.cn http://www.morning.kjyhh.cn.gov.cn.kjyhh.cn http://www.morning.rzscb.cn.gov.cn.rzscb.cn http://www.morning.tpnxr.cn.gov.cn.tpnxr.cn http://www.morning.mfxcg.cn.gov.cn.mfxcg.cn http://www.morning.trplf.cn.gov.cn.trplf.cn