Using libcurl within a Plugin

Hello everyone.

I’ve been trying to use libcurl in my plugin, but I’ve hit several brick walls.

First, I’ve tried to use the included libcurl, but no dice.

Secondly, I grabbed the libcurl and plopped it in the project’s ThirdParty folder, and then adding it to my plugin’s Build.cs via PublicIncludePaths.Add and PublicAdditionalLibraries.Add, but again it failed.

The error messages that I’m getting over and over are these:

  [2017.12.15-10.09.38:241][751]CompilerResultsLog: New page: Compilation - 15 Dec 2017 14:09:38
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Compiling game modules for hot reload
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Performing 4 actions (4 in parallel)
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Module.TiniestAnalytics.cpp
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Module.TiniestAnalytics.gen.cpp
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\winnt.h(536): warning C4005: 'TEXT': macro redefinition
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/Platform.h(839) : note: see previous definition of 'TEXT'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\winnt.h(17005): warning C4668: '_APISET_RTLSUPPORT_VER' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\interlockedapi.h(73): warning C4668: '_APISET_INTERLOCKED_VER' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\processthreadsapi.h(1170): warning C4668: '_WIN32_WINNT_WINTHRESHOLD' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\securitybaseapi.h(357): warning C4668: '_APISET_SECURITYBASE_VER' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\securitybaseapi.h(472): warning C4668: '_APISET_SECURITYBASE_VER' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\securitybaseapi.h(1302): warning C4668: '_APISET_SECURITYBASE_VER' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\winbase.h(8618): warning C4668: 'NTDDI_WIN7SP1' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(67) : error C2039: '_InterlockedIncrement': is not a member of 'FWindowsPlatformAtomics'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: C:\Program Files\Epic Games\UE_4.17\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformAtomics.h(14) : note: see declaration of 'FWindowsPlatformAtomics'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(67) : error C2665: '_InterlockedIncrement': none of the 4 overloads could convert all the argument types
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\winbase.h(8844): note: could be 'unsigned __int64 _InterlockedIncrement(volatile unsigned __int64 *)'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\winbase.h(8833): note: or       'unsigned long _InterlockedIncrement(volatile unsigned long *)'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\winbase.h(8824): note: or       'unsigned int _InterlockedIncrement(volatile unsigned int *)'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\INCLUDE\intrin0.h(186): note: or       'long _InterlockedIncrement(volatile long *)'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(67) : note: while trying to match the argument list '(volatile int64 *)'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(79) : error C2039: '_InterlockedAdd': is not a member of 'FWindowsPlatformAtomics'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: C:\Program Files\Epic Games\UE_4.17\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformAtomics.h(14) : note: see declaration of 'FWindowsPlatformAtomics'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(79) : error C2664: 'LONG _InterlockedAdd(volatile LONG *,LONG)': cannot convert argument 1 from 'volatile int64 *' to 'volatile LONG *'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(79) : note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(90) : error C2039: '_InterlockedDecrement': is not a member of 'FWindowsPlatformAtomics'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: C:\Program Files\Epic Games\UE_4.17\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformAtomics.h(14) : note: see declaration of 'FWindowsPlatformAtomics'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(90) : error C2665: '_InterlockedDecrement': none of the 4 overloads could convert all the argument types
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\winbase.h(8875): note: could be 'unsigned __int64 _InterlockedDecrement(volatile unsigned __int64 *)'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\winbase.h(8864): note: or       'unsigned long _InterlockedDecrement(volatile unsigned long *)'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\winbase.h(8855): note: or       'unsigned int _InterlockedDecrement(volatile unsigned int *)'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\INCLUDE\intrin0.h(151): note: or       'long _InterlockedDecrement(volatile long *)'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(90) : note: while trying to match the argument list '(volatile int64 *)'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(102) : error C2039: '_InterlockedAdd': is not a member of 'FWindowsPlatformAtomics'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: C:\Program Files\Epic Games\UE_4.17\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformAtomics.h(14) : note: see declaration of 'FWindowsPlatformAtomics'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(102) : error C2664: 'LONG _InterlockedAdd(volatile LONG *,LONG)': cannot convert argument 1 from 'volatile int64 *' to 'volatile LONG *'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(102) : note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(114) : error C2039: '_InterlockedExchange': is not a member of 'FWindowsPlatformAtomics'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: C:\Program Files\Epic Games\UE_4.17\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformAtomics.h(14) : note: see declaration of 'FWindowsPlatformAtomics'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(114) : error C2665: '_InterlockedExchange': none of the 4 overloads could convert all the argument types
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\winbase.h(8910): note: could be 'unsigned __int64 _InterlockedExchange(volatile unsigned __int64 *,unsigned __int64)'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\winbase.h(8898): note: or       'unsigned long _InterlockedExchange(volatile unsigned long *,unsigned long)'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\winbase.h(8888): note: or       'unsigned int _InterlockedExchange(volatile unsigned int *,unsigned int)'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\INCLUDE\intrin0.h(153): note: or       'long _InterlockedExchange(volatile long *,long)'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(114) : note: while trying to match the argument list '(volatile int64 *, int64)'
  [2017.12.15-10.09.38:242][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(125) : error C2039: '_InterlockedExchange': is not a member of 'FWindowsPlatformAtomics'
  [2017.12.15-10.09.38:243][751]CompilerResultsLog: Error: C:\Program Files\Epic Games\UE_4.17\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformAtomics.h(14) : note: see declaration of 'FWindowsPlatformAtomics'
  [2017.12.15-10.09.38:243][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(125) : error C2665: '_InterlockedExchange': none of the 4 overloads could convert all the argument types
  [2017.12.15-10.09.38:243][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\winbase.h(8910): note: could be 'unsigned __int64 _InterlockedExchange(volatile unsigned __int64 *,unsigned __int64)'
  [2017.12.15-10.09.38:243][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\winbase.h(8898): note: or       'unsigned long _InterlockedExchange(volatile unsigned long *,unsigned long)'
  [2017.12.15-10.09.38:243][751]CompilerResultsLog: C:\Program Files (x86)\Windows Kits\8.1\include\um\winbase.h(8888): note: or       'unsigned int _InterlockedExchange(volatile unsigned int *,unsigned int)'
  [2017.12.15-10.09.38:243][751]CompilerResultsLog: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\INCLUDE\intrin0.h(153): note: or       'long _InterlockedExchange(volatile long *,long)'
  [2017.12.15-10.09.38:243][751]CompilerResultsLog: Error: c:\program files\epic games\ue_4.17\engine\source\runtime\core\public\HAL/ThreadSafeCounter64.h(125) : note: while trying to match the argument list '(volatile int64 *, int)'
  [2017.12.15-10.09.38:243][751]CompilerResultsLog: Error: C:\Program Files\Epic Games\UE_4.17\Engine\Source\Runtime\Engine\Classes\Engine/TextureCube.h(69) : error C3668: 'UTextureCube::UpdateResourceW': method with override specifier 'override' did not override any base class methods
  [2017.12.15-10.09.38:243][751]CompilerResultsLog: Error: C:\Program Files\Epic Games\UE_4.17\Engine\Source\Runtime\Engine\Classes\Engine/CanvasRenderTarget2D.h(43) : error C3668: 'UCanvasRenderTarget2D::UpdateResourceW': method with override specifier 'override' did not override any base class methods
  [2017.12.15-10.09.38:243][751]CompilerResultsLog: ERROR: UBT ERROR: Failed to produce item: C:\Users\alexg\Documents\Unreal Projects\PluginDevelopment\Plugins\TiniestAnalytics\Binaries\Win64\UE4Editor-TiniestAnalytics-6443.dll
  [2017.12.15-10.09.38:243][751]CompilerResultsLog: Total build time: 15.62 seconds (Local executor: 0.00 seconds)

You are aware of HTTP module on UE4?

Yeah, I am. But the library I’m trying to port is heavily dependant on libcurl. I’d rather not rewrite the whole thing if UE4 offers libcurl.

try adding this to build script

AddEngineThirdPartyPrivateStaticDependencies(Target, "libcurl");

Also you have soem missing definition like you bypassing make system for library you use, you should build the library with it’s own build system. I once tried to use third party library and by using this i was able to build it based on it’s own build system: