Skip to content

ProgramBase/ZXingForUnreal5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

ZXingForUnreal5

x64 Only UE5.4

集成说明

下面的代码片段展示了如何在模块的 xx.Build.cs 中集成第三方库 ZXing(适用于 Win64 x64):

// 开启 C++20 (ZXing 需要)
CppStandard = CppStandardVersion.Cpp20;
// --- ZXing 集成 ---
// 1. 定位到 ThirdParty 目录
// ModuleDirectory 是当前 .Build.cs 所在目录
string ThirdPartyPath = Path.GetFullPath(Path.Combine(ModuleDirectory, "../ThirdParty"));

string ZXingIncludePath = Path.Combine(ThirdPartyPath, "ZXing", "Include");
string ZXingLibPath = Path.Combine(ThirdPartyPath, "ZXing", "Lib", "Win64", "ZXing.lib");

// 2. 检查文件是否存在 (良好的习惯,防止路径错误导致莫名其妙的链接失败)
if (!Directory.Exists(ZXingIncludePath))
{
	throw new BuildException("ZXing Include path not found: " + ZXingIncludePath);
}

// 3. 添加头文件包含路径
// 这样在代码里就可以写 #include "ZXing/ReadBarcode.h"
PublicIncludePaths.Add(ZXingIncludePath);

// 4. 链接静态库
if (Target.Platform == UnrealTargetPlatform.Win64)
{
	PublicAdditionalLibraries.Add(ZXingLibPath);
}
// --- 集成结束 ---

注意

  • 文件: 将上述修改写入你的模块构建文件:xx.Build.cs(将 xx 替换为你的模块名)。
  • 目录: 请确保工程中的 ThirdParty/ZXing/IncludeThirdParty/ZXing/Lib/Win64/ZXing.lib 路径存在且正确。
  • 平台: 目前示例仅为 Win64 平台(x64)。

如果你需要我把这段代码直接插入某个具体的 .Build.cs 文件中,告诉我模块名,我可以为你修改对应文件。

在插件(Plugins)中集成示例

如果你要把 ZXing 放到一个插件里(例如 MyCustomPlugin),建议的目录结构如下:

MyProject/
└── Plugins/
	└── MyCustomPlugin/
		├── Source/
		│   ├── MyCustomPlugin/
		│   │   ├── MyCustomPlugin.Build.cs
		│   │   └── ...
		│   └── ThirdParty/           <-- 在插件 Source 下新建
		│       └── ZXing/            <-- 新建 ZXing 文件夹
		│           ├── Include/      <-- 将上面 Include 下的 "ZXing" 文件夹整个拷进来
		│           │   └── ZXing/    <-- 结构应该是 Include/ZXing/ReadBarcode.h
		│           └── Lib/
		│               └── Win64/    <-- 将 lib/ZXing.lib 拷进来

要点说明:

  • MyCustomPlugin/Source/ThirdParty/ZXing/Include 中放入 ZXing 头文件目录(保证路径为 Include/ZXing/...)。
  • MyCustomPlugin/Source/ThirdParty/ZXing/Lib/Win64 中放入 ZXing.lib
  • MyCustomPlugin.Build.cs 中使用本 README 中上方的 xx.Build.cs 片段(将 ModuleDirectory 用于定位插件的 Source 目录),例如把 ThirdPartyPath 定位为 Path.Combine(ModuleDirectory, "../ThirdParty"),然后添加 PublicIncludePaths.Add(ZXingIncludePath) 并在 Win64 平台下添加 PublicAdditionalLibraries.Add(ZXingLibPath)

如果你愿意,我可以把代码片段直接插入到 MyCustomPlugin.Build.cs(或你指定的模块构建文件)中;请告诉我模块名。

About

x64 Only

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published