Question/Problem
If I build in Development editor configuration, the build is successful. But when trying to package the project, I get lots of already defined in libcurl_a.lib
linker errors, because I am linking in libssl.lib and libcrypto.lib via a custom plugin (that relies on custom C++ libraries using OpenSSL). This is a very major issue as it is restricting access to complex libraries built on top of using that OpenSSL version. How can I disable libcurl and related/conflicting modules from builds/packaging?
UATHelper: Packaging (Windows (64-bit)): libssl.lib(ssl_lib.obj) : error LNK2005: ssl3_undef_enc_method already defined in libcurl_a.lib(ssl_lib.obj)
UATHelper: Packaging (Windows (64-bit)): libssl.lib(ssl_lib.obj) : error LNK2005: SSL_version_str already defined in libcurl_a.lib(ssl_lib.obj)
UATHelper: Packaging (Windows (64-bit)): libssl.lib(t1_lib.obj) : error LNK2005: TLSv1_enc_data already defined in libcurl_a.lib(t1_lib.obj)
UATHelper: Packaging (Windows (64-bit)): libssl.lib(t1_lib.obj) : error LNK2005: TLSv1_1_enc_data already defined in libcurl_a.lib(t1_lib.obj)
UATHelper: Packaging (Windows (64-bit)): libssl.lib(t1_lib.obj) : error LNK2005: TLSv1_2_enc_data already defined in libcurl_a.lib(t1_lib.obj)
UATHelper: Packaging (Windows (64-bit)): libssl.lib(d1_lib.obj) : error LNK2005: DTLSv1_enc_data already defined in libcurl_a.lib(d1_lib.obj)
UATHelper: Packaging (Windows (64-bit)): libssl.lib(d1_lib.obj) : error LNK2005: DTLSv1_2_enc_data already defined in libcurl_a.lib(d1_lib.obj)
UATHelper: Packaging (Windows (64-bit)): libssl.lib(s3_lib.obj) : error LNK2005: SSLv3_enc_data already defined in libcurl_a.lib(s3_lib.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(cryptlib.obj) : error LNK2005: OPENSSL_NONPIC_relocated already defined in libcurl_a.lib(cryptlib.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(v3_ncons.obj) : error LNK2005: v3_name_constraints already defined in libcurl_a.lib(v3_ncons.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_encrypt already defined in libcurl_a.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_decrypt already defined in libcurl_a.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_ecb_encrypt already defined in libcurl_a.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_ccm64_encrypt_blocks already defined in libcurl_a.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_ccm64_decrypt_blocks already defined in libcurl_a.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_ctr32_encrypt_blocks already defined in libcurl_a.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_xts_encrypt already defined in libcurl_a.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_xts_decrypt already defined in libcurl_a.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_cbc_encrypt already defined in libcurl_a.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_set_decrypt_key already defined in libcurl_a.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_set_encrypt_key already defined in libcurl_a.lib(aesni-x86_64.obj)
It is very similar to Shipping plugin with ThirdParty lib with libCURL - Plugins - Epic Developer Community Forums (that was never answered), except I am using another version of OpenSSL instead of another version of libcurl.
Technical details
Unreal Engine: 4.19.2 (pre-built Launcher version).
Compiler/IDE: Visual Studio 2015 Enterprise Update 3
OpenSSL: 1.1.0h
Operating System: Windows 7 Ultimate x64 Service Pack 1
Relevant links studied (irrelevant omitted)
- https://docs.unrealengine.com/en-us/Programming/UnrealBuildSystem/ModuleFiles
- https://answers.unrealengine.com/questions/82448/how-to-activate-the-built-in-library-ue4-libcurl-t.html
- https://answers.unrealengine.com/questions/254591/libcurl-declaration.html
- https://answers.unrealengine.com/questions/428486/programming-with-third-party-libcurl.html
- https://answers.unrealengine.com/questions/736377/using-libcurl-withing-a-plugin.html
- https://answers.unrealengine.com/questions/325380/reading-a-file-online.html
- https://forums.unrealengine.com/unreal-engine/announcements-and-releases/1374252-unreal-engine-4-18-released
Approaches NOT working
[1]
Adding to project DefaultEngine.ini
:
[Networking]
UseLibCurl=false
[2]
Adding to .Build.cs of both plugin module (linking in the libraries) AND main project:
PublicDependencyModuleNames.Remove("libcurl");
PublicDependencyModuleNames.Remove("HTTP");
PublicDependencyModuleNames.Remove("OpenSSL");
PrivateDependencyModuleNames.Remove("libcurl");
PrivateDependencyModuleNames.Remove("HTTP");
PrivateDependencyModuleNames.Remove("OpenSSL");
PublicAdditionalLibraries.Remove("libcurl_a.lib");
PublicAdditionalLibraries.Remove("libcurl_a");
[3]
Unchecking the “Verify Peer” box in Edit -> Project Settings -> Network -> Libcurl
.
[4]
Disabling all of the TCP/UDP Messaging (and others in the list) plugins under Edit -> Project Settings -> Plugins
category/section.
[5]
Commenting out libcurl linking in UE_4.19\Engine\Source\ThirdParty\libcurl\libcurl.Build.cs
:
// Commented out.
//PublicAdditionalLibraries.Add("libcurl_a.lib");
//PublicDefinitions.Add("CURL_STATICLIB=1");
Produces different errors (seem to be related to OpenSSL more directly this time).
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(cryptlib.obj) : error LNK2005: OPENSSL_NONPIC_relocated already defined in libeay.lib(cryptlib.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_encrypt already defined in libeay.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_decrypt already defined in libeay.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_ecb_encrypt already defined in libeay.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_ccm64_encrypt_blocks already defined in libeay.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_ccm64_decrypt_blocks already defined in libeay.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_ctr32_encrypt_blocks already defined in libeay.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_xts_encrypt already defined in libeay.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_xts_decrypt already defined in libeay.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_cbc_encrypt already defined in libeay.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_set_decrypt_key already defined in libeay.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libcrypto.lib(aesni-x86_64.obj) : error LNK2005: aesni_set_encrypt_key already defined in libeay.lib(aesni-x86_64.obj)
UATHelper: Packaging (Windows (64-bit)): libssl.lib(ssl_lib.obj) : error LNK2005: ssl3_undef_enc_method already defined in ssleay.lib(ssl_lib.obj)
UATHelper: Packaging (Windows (64-bit)): libssl.lib(ssl_lib.obj) : error LNK2005: SSL_version_str already defined in ssleay.lib(ssl_lib.obj)
UATHelper: Packaging (Windows (64-bit)): libssl.lib(t1_lib.obj) : error LNK2005: TLSv1_enc_data already defined in ssleay.lib(t1_lib.obj)
UATHelper: Packaging (Windows (64-bit)): libssl.lib(t1_lib.obj) : error LNK2005: TLSv1_1_enc_data already defined in ssleay.lib(t1_lib.obj)
UATHelper: Packaging (Windows (64-bit)): libssl.lib(t1_lib.obj) : error LNK2005: TLSv1_2_enc_data already defined in ssleay.lib(t1_lib.obj)
UATHelper: Packaging (Windows (64-bit)): libssl.lib(d1_lib.obj) : error LNK2005: DTLSv1_enc_data already defined in ssleay.lib(d1_lib.obj)
UATHelper: Packaging (Windows (64-bit)): libssl.lib(d1_lib.obj) : error LNK2005: DTLSv1_2_enc_data already defined in ssleay.lib(d1_lib.obj)
UATHelper: Packaging (Windows (64-bit)): libssl.lib(s3_lib.obj) : error LNK2005: SSLv3_enc_data already defined in ssleay.lib(s3_lib.obj)
As well as new errors:
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_easy_unescape
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_free
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_global_init_mem
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_global_cleanup
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_slist_append
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_slist_free_all
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_share_init
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_share_setopt
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_version_info
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_easy_strerror
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_easy_init
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_easy_setopt
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_easy_cleanup
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_easy_getinfo
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_multi_init
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_multi_add_handle
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_multi_remove_handle
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_multi_perform
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_multi_cleanup
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_multi_info_read
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_multi_strerror
UATHelper: Packaging (Windows (64-bit)): UE4-HTTP.lib(Module.HTTP.cpp.obj) : error LNK2001: unresolved external symbol curl_multi_setopt
[6]
Rebuilding Intermediate
directory.
[7]
Building from Visual Studio in Shipping
configuraion (produces identical errors as through Editor packaging).
[8]
Disabling most plugins ( SteamVR
, OculusVR
, CryptoKeys
, OnlineSubsystem
, OnlineSubsystemUtils
, OnlineSubsystemNull
, OnlineSubsystemIOS
, GoogleCloudMessaging
, NetcodeUnitTest
, NUTUnrealEngine4
, HTML5Networking
, UdpMessaging
, TcpMessaging
, UObjectPlugin
, IOSDeviceProfileSelector
, AndroidDeviceProfileSelector
, LocationServicesBPLibrary
, AppleARKit
, AndroidPermission
, OnlineSubsystemGooglePlay
), most notably AES Network Pakcet Handler
and Platform Cryptography plugin
(although the latter two aren’t automatically added to the .uproject, they are unchecked in the Editor).
[9]
Trying to build as “Modular” instead of default “Monolithic” by adding LinkType = TargetLinkType.Modular;
to <GameProjectName>.Target.cs
fails with the following errors:
UATHelper: Packaging (Windows (64-bit)): LINK : fatal error LNK1181: cannot open input file 'C:\Program Files\Epic Games\UE_4.19\Engine\Intermediate\Build\Win64\UE4\Development\UE4-CoreUObject.lib'
UATHelper: Packaging (Windows (64-bit)): LINK : fatal error LNK1181: cannot open input file 'C:\Program Files\Epic Games\UE_4.19\Engine\Intermediate\Build\Win64\UE4\Development\UE4-Core.lib'
[10]
Trying to add the updated 1.1.0 OpenSSL version in the same way the existing 1.0.2 version is already present (in the Engine ThirdParty directory), through C:\Program Files\Epic Games\UE_4.19\Engine\Source\ThirdParty\OpenSSL\OpenSSL.Build.cs
. After, adding the module dependency for that PrivateDependencyModuleNames.Add("OpenSSL");
to <GameProject>.Build.cs
(instead of linking OpenSSL through the plugin). But that produced the same behavior/errors as manually linking through the plugin.
Test project
I have created a test project as simplified version of the issue. It uses the same setup (custom plugin with custom C++ library using OpenSSL) that simply initializes two OpenSSL structures. There are only a few errors with that test project, but they are of the same nature, so the underlying issue is the same. The project contains pre-compiled libraries so it should be very easy to use.
Small note: Although it’s a .zip archive file, there’s actually a .7z archive inside the .zip archive, due to the 5.2MB upload limit.