Hello,
I am trying to build a plugin to expose some of the functionality of LibSSH2 to blueprints. But every time I try to build the plugin I am getting link errors.
So this is what I do first:
- I built the .lib and .dll files like described here: libssh2/INSTALL_CMAKE.md at master · libssh2/libssh2 · GitHub. My build script was:
git clone https://github.com/libssh2/libssh2.git
cd libssh2
mkdir bin
cd bin
cmake -DBUILD_SHARED_LIBS=ON ..
cmake --build . --target install
Giving me the libssh2.dll and libssh2.lib file in the \bin\src\Debug folder.
-
I put the .dll and .lib files in their respective folders, like shown in this picture.
-
Edited the build file of my plugin (C_SSH.Build.cs) so it looks like this:
using System;
using System.IO;
using UnrealBuildTool;
public class C_SSH : ModuleRules
{
private string ModulePath
{
get { return ModuleDirectory; }
}
private string ThirdPartyPath
{
get { return Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty/")); }
}
private string BinariesPath
{
get { return Path.GetFullPath(Path.Combine(ModulePath, "../../Binaries/")); }
}
private string LibraryPath
{
get { return Path.GetFullPath(Path.Combine(ThirdPartyPath, "LibSSH2", "Lib")); }
}
public C_SSH(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PublicIncludePaths.AddRange(new string[] { "C_SSH/Public", Path.Combine(ThirdPartyPath, "LibSSH2", "Include"), });
PrivateIncludePaths.AddRange(new string[] { "Private", });
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "Projects", "InputCore", "Icmp" });
PrivateDependencyModuleNames.AddRange(new string[] { "CoreUObject", });
DynamicallyLoadedModuleNames.AddRange(new string[] { });
LoadLibSSH2(Target);
}
public bool LoadLibSSH2(ReadOnlyTargetRules Target)
{
bool isLibrarySupported = false;
if (Target.Platform == UnrealTargetPlatform.Win64)
{
isLibrarySupported = true;
// Add the import library
PublicAdditionalLibraries.Add(Path.Combine(LibraryPath, "Win64", "libssh2.lib"));
// Delay-load the DLL, so we can load it from the right place first
PublicDelayLoadDLLs.Add("libssh2.dll");
}
return isLibrarySupported;
}
}
But after building the project I get these errors:
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_init referenced in function "private: void __cdecl SSH_Impl::Connect_Int(void)" (?Connect_Int@SSH_Impl@@AEAAXXZ)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_exit referenced in function "public: __cdecl SSH_Impl::~SSH_Impl(void)" (??1SSH_Impl@@QEAA@XZ)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_session_init_ex referenced in function "private: void __cdecl SSH_Impl::Connect_Int(void)" (?Connect_Int@SSH_Impl@@AEAAXXZ)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_session_handshake referenced in function "private: void __cdecl SSH_Impl::Connect_Int(void)" (?Connect_Int@SSH_Impl@@AEAAXXZ)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_session_disconnect_ex referenced in function "public: __cdecl SSH_Impl::~SSH_Impl(void)" (??1SSH_Impl@@QEAA@XZ)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_session_free referenced in function "public: __cdecl SSH_Impl::~SSH_Impl(void)" (??1SSH_Impl@@QEAA@XZ)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_session_hostkey referenced in function "private: void __cdecl SSH_Impl::Connect_Int(void)" (?Connect_Int@SSH_Impl@@AEAAXXZ)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_session_last_error referenced in function "private: void __cdecl SSH_Impl::ExecuteCommand_Int(class FString const &)" (?ExecuteCommand_Int@SSH_Impl@@AEAAXAEBVFString@@@Z)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_session_block_directions referenced in function "private: void __cdecl SSH_Impl::ExecuteCommand_Int(class FString const &)" (?ExecuteCommand_Int@SSH_Impl@@AEAAXAEBVFString@@@Z)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_userauth_password_ex referenced in function "public: bool __cdecl SSH_Impl::Authenticate(void)" (?Authenticate@SSH_Impl@@QEAA_NXZ)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_channel_open_ex referenced in function "private: void __cdecl SSH_Impl::ExecuteCommand_Int(class FString const &)" (?ExecuteCommand_Int@SSH_Impl@@AEAAXAEBVFString@@@Z)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_channel_process_startup referenced in function "private: void __cdecl SSH_Impl::ExecuteCommand_Int(class FString const &)" (?ExecuteCommand_Int@SSH_Impl@@AEAAXAEBVFString@@@Z)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_channel_read_ex referenced in function "private: void __cdecl SSH_Impl::ExecuteCommand_Int(class FString const &)" (?ExecuteCommand_Int@SSH_Impl@@AEAAXAEBVFString@@@Z)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_channel_get_exit_status referenced in function "private: void __cdecl SSH_Impl::ExecuteCommand_Int(class FString const &)" (?ExecuteCommand_Int@SSH_Impl@@AEAAXAEBVFString@@@Z)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_channel_get_exit_signal referenced in function "private: void __cdecl SSH_Impl::ExecuteCommand_Int(class FString const &)" (?ExecuteCommand_Int@SSH_Impl@@AEAAXAEBVFString@@@Z)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_channel_close referenced in function "private: void __cdecl SSH_Impl::ExecuteCommand_Int(class FString const &)" (?ExecuteCommand_Int@SSH_Impl@@AEAAXAEBVFString@@@Z)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_channel_free referenced in function "private: void __cdecl SSH_Impl::ExecuteCommand_Int(class FString const &)" (?ExecuteCommand_Int@SSH_Impl@@AEAAXAEBVFString@@@Z)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_knownhost_init referenced in function "private: void __cdecl SSH_Impl::Connect_Int(void)" (?Connect_Int@SSH_Impl@@AEAAXXZ)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_knownhost_checkp referenced in function "private: void __cdecl SSH_Impl::Connect_Int(void)" (?Connect_Int@SSH_Impl@@AEAAXXZ)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_knownhost_free referenced in function "private: void __cdecl SSH_Impl::Connect_Int(void)" (?Connect_Int@SSH_Impl@@AEAAXXZ)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_knownhost_readfile referenced in function "private: void __cdecl SSH_Impl::Connect_Int(void)" (?Connect_Int@SSH_Impl@@AEAAXXZ)
1>Module.C_SSH.cpp.obj : error LNK2019: unresolved external symbol __imp_libssh2_knownhost_writefile referenced in function "private: void __cdecl SSH_Impl::Connect_Int(void)" (?Connect_Int@SSH_Impl@@AEAAXXZ)
Does anyone have any idea on how to fix this? I already rebuilt the project, regenerated the visual studio project files. But nothing seems to work.
Any help would be so nice!
Thank you!
