首页 > 解决方案 > UE4 打包错误:与 OpenSSL 的链接问题

问题描述

我目前正在尝试使用 Unreal Engine 4 制作一个项目,该项目执行来自 C++ 代码的 HTTPS 请求。

为了实现这个目标,我使用了库c++-httplib,它需要 OpenSSL,所以我将它添加到我的项目中,给出了文件中的位置include和文件,尤其是et 。libProject.Build.cslibssl.liblibcrypto.lib

在编辑器中一切正常,但是一旦我尝试打包我的项目,我就会收到以下错误(第 11-12 行)

1:UEBuildTarget.GenerateManifest: Writing manifest to C:\MyProject\Intermediate\Build\Manifest.xml
2:ActionGraph.IsActionOutdated: MyProject.exe: Produced item "MyProject.exe" doesn't exist.
3:ActionGraph.DeleteOutdatedProducedItems: Deleting outdated item: C:\MyProject\Binaries\Win64\MyProject.pdb
4:UEBuildTarget.TryRecycleVersionManifests: Target is not using a version file.
5:ParallelExecutor.ExecuteActions: Building 1 action with 12 processes...
6:ParallelExecutor.ExecuteActions:   [1/1] MyProject.exe
7:ParallelExecutor.ExecuteActions:   vpxmd.lib(vpx_src_vpx_codec.obj) : .netmodule ou module MSIL compil� avec /GL trouv�; red�marrage de l'�dition de liens avec /LTCG�; ajoutez /LTCG � la ligne de commande de l'�dition de liens pour am�liorer les performances de l'�diteur de liens
8:ParallelExecutor.ExecuteActions:      Cr�ation de la biblioth�que C:\MyProject\Binaries\Win64\MyProject.lib et de l'objet C:\MyProject\Binaries\Win64\MyProject.exp
9:ParallelExecutor.ExecuteActions:   G�n�ration de code en cours
10:ParallelExecutor.ExecuteActions:   Fin de la g�n�ration du code
11:ParallelExecutor.ExecuteActions:   libcurl_a.lib(pem_all.obj) : error LNK2005: PEM_read_bio_RSAPrivateKey d�j� d�fini(e) dans libcrypto64MD.lib(libcrypto-1_1-x64.dll)
12:ParallelExecutor.ExecuteActions:   libcurl_a.lib(pem_pkey.obj) : error LNK2005: PEM_read_bio_PrivateKey d�j� d�fini(e) dans libcrypto64MD.lib(libcrypto-1_1-x64.dll)
13:ParallelExecutor.ExecuteActions:   C:\MyProject\Binaries\Win64\MyProject.exe : fatal error LNK1169: un ou plusieurs symboles d�finis � diff�rentes reprises ont �t� rencontr�s
14:Log.WriteException: ==============================================================================
15:Log.WriteException: ERROR: UBT ERROR: Failed to produce item: C:\MyProject\Binaries\Win64\MyProject.exe
16:Log.WriteException:        (see C:\Users\etudiant\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Program+Files+Epic+Games+UE_4.21\UBT-MyProject-Win64-Development.txt for full exception trace)
17:Log.WriteException: 
18:Log.WriteException: BuildException: UBT ERROR: Failed to produce item: C:\MyProject\Binaries\Win64\MyProject.exe
19:Log.WriteException:    à UnrealBuildTool.ActionGraph.ExecuteActions(BuildConfiguration BuildConfiguration, List`1 ActionsToExecute, String& ExecutorName, String TargetInfoForTelemetry, EHotReload HotReload) dans D:\Build\++UE4\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\ActionGraph.cs:ligne 507
20:Log.WriteException:    à UnrealBuildTool.UnrealBuildTool.RunUBT(BuildConfiguration BuildConfiguration, String[] Arguments, FileReference ProjectFile, Boolean bCatchExceptions) dans D:\Build\++UE4\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:ligne 1699
21:Log.WriteException: ==============================================================================
22:UnrealBuildTool.RunUBT: Total build time: 42,37 seconds (Parallel executor: 0,00 seconds)

而且我不知道我能做些什么。

标签: c++opensslunreal-engine4

解决方案


主要问题是链接器错误LNK2005,这意味着您正在从两个不同的地方链接相同的符号(代码)。

即来自“libcurl_a.lib”和“libcrypto64MD.lib”的“PEM_read_bio_RSAPrivateKey”和“PEM_read_bio_PrivateKey”。

猜测“libcurl_a”库已经静态链接了openssl,您正在尝试链接到openssl动态库“libcrypto64MD”(libcrypto-1_1-x64.dll)。

您可以删除“libcrypto64MD.lib”的链接并从“libcurl_a.lib”获取打开的 ssl。如果由于缺少符号而不能,则可能需要编译或获取使用 dll 版本的 openssl 库的不同版本的 libcurl。


推荐阅读