#pragma once
#ifndef __MYTEST_LIB_H__
#define __MYTEST_LIB_H__
#include <string>
#include <iostream>
int myPrint( int _age);
#endif
#include "MyTestLib.h"
int myPrint(int _age)
{
return _age + 1000;
}
using System.IO;
namespace UnrealBuildTool.Rules
{
public class JsonPlugin : ModuleRules
{
private string ModulePath
{
// get { return Path.GetDirectoryName(RulesCompiler.GetModuleFilename(this.GetType().Name)); }
get { return ModuleDirectory; }
}
private string ThirdPartyPath
{
get { return Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty/")); }
}
private string MyLibPath //第三方库MyTestLib的目录
{
get { return Path.GetFullPath(Path.Combine(ThirdPartyPath, "mylib")); }
}
public JsonPlugin(TargetInfo Target)
{
PublicIncludePaths.AddRange(
new string[] {
"JsonPlugin/Public",
// ... add public include paths required here ...
}
);
PrivateIncludePaths.AddRange(
new string[] {
"JsonPlugin/Private",
// ... add other private include paths required here ...
}
);
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"CoreUObject",
"Engine",
"HTTP",
"Json"
// ... add other public dependencies that you statically link with here ...
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
// ... add private dependencies that you statically link with here ...
}
);
DynamicallyLoadedModuleNames.AddRange(
new string[]
{
// ... add any modules that your module loads dynamically here ...
}
);
LoadThirdPartyLib(Target);
}
public bool LoadThirdPartyLib(TargetInfo Target)
{
bool isLibrarySupported = false;
if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))//平台判断
{
isLibrarySupported = true;
System.Console.WriteLine("----- isLibrarySupported true");
//string PlatformSubPath = (Target.Platform == UnrealTargetPlatform.Win64) ? "Win64" : "Win32";
string LibrariesPath = Path.Combine(MyLibPath, "Lib");
PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath,/* PlatformSubPath,*/ "MyTestLib.lib"));//加载第三方静态库.lib
}
if (isLibrarySupported) //成功加载库的情况下,包含第三方库的头文件
{
// Include path
System.Console.WriteLine("----- PublicIncludePaths.Add true");
PublicIncludePaths.Add(Path.Combine(MyLibPath, "Include"));
}
return isLibrarySupported;
}
}
}
#include "../ThirdParty/mylib/Include/MyTestLib.h"
int UJsonFunction::MyOutput()
{
int str = myPrint(100); //lib 里的函数
return str;
}
原文最早发布于:https://blog.csdn.net/Szu_IT_Man/article/details/58232638
原文:https://www.cnblogs.com/shiroe/p/14732889.html