본문 바로가기

프로그래밍/Unreal

[UE4] Using Static Library

오픈소스 static library를 내 모듈에 추가하고자 할때~



우선 해당 오픈소스 라이브러리의 빌드

구성 : 활성(Release), 플랫폼 : x64


구성속성 - 일반 

Windows SDK 버전 : 8.1

구성형식 : 정적 라이브러리(.lib)



구성속성 - C/C++ - 코드생성

런타임 라이브러리 : 다중 스레드 DLL(/MD)




빌드한 lib 파일과 include 폴더를 ThirdParty 폴더로 복사


예를들어 my.lib 파일이라면

언리얼프로젝트루트/ThirdParty/MyLib/include/

언리얼프로젝트루트/ThirdParty/MyLib/bin/

언리얼프로젝트루트/ThirdParty/MyLib/bin_x64/




모듈 Build.cs 수정

해당 라이브러리를 사용할 모듈의 Build.cs 파일을 수정한다.

using System.IO;


public class MyModuleName : ModuleRules

{    


public MyModuleName(ReadOnlyTargetRules Target) : base(Target)

{

.

.

.

.

//모듈 생성자에 아래 루틴 추가

if((Target.Platform == UnrealTargetPlatform.Win64 ) || (Target.Platform == UnrealTargetPlatform.Win32) )

{

string ThirdPartyPath = Path.GetFullPath( Path.Combine(ModuleDirectory, "../../ThirdParty/"));

string IncludePath = ThirdPartyPath + "MyLib/include/";

string LibraryName = "my.lib";


string LibraryPath = ThirdPartyPath ;

if( Target.Platform == UnrealTargetPlatform.Win64 )

{

LibraryPath += "bin_x64/";

} else 

LibraryPath += "bin/";

}


PublicLibraryPaths.Add(LibraryPath);

PublicIncludePaths.Add( IncludePath );

PublicAdditionalLibraries.Add(Path.Combine(LibraryPath, LibraryName));


}

}

}




소스코드에서 라이브러리의 헤더 접근을 위해 

프로젝트속성 - VC++ 디렉터리 - 포함디렉터리

라이브러리의 include path 추가 : ..\..\ThirdParty\MyLib\include;


'프로그래밍 > Unreal' 카테고리의 다른 글

[UE4] 이미지 파일 동적으로 로드하기  (0) 2018.07.05
[UE4] 언리얼 엔진 빌드  (1) 2018.06.01
[UE4] Dedicated Server  (0) 2018.05.31
[UE4] VR 컨트롤러 IK  (0) 2018.01.24
[UE4] 관람자 화면  (0) 2018.01.04
[UE4] 동적 텍스처  (0) 2017.12.18
[UE4] 디버그 로그 출력  (0) 2017.11.13
[UE4] 유리 매터리얼  (0) 2017.10.15
[UE4] 레벨 스트리밍  (0) 2017.10.15
[UE4] UI 관련 내용  (0) 2017.09.26