Help connecting UE4 to perforce on Linux

Hi all, I have a problem using Perfoce with Unreal 4.27.2.

I have built Unreal from the github source for Ubuntu. All is working well development-wise, we are switching to Perforce for version control and when trying to connect I am met with the following error in the console.

P4ERROR: Failed to connect to source control provider.
SSL library must be at least version 1.0.1.
Port=ssl.xxxx:1666, User=xxxx, ClientSpec=, Ticket=

I have p4 installed on the PC and there are no issues connecting manually from the CLI:

âžś  ~ export P4PORT=ssl:xxxx:1666
âžś  ~ export P4USER=xxxx
âžś  ~ p4 users
Perforce password (P4PASSWD) invalid or unset.
Attempting login for user 'xxxx' against server 'ssl:xxxx:1666'
Enter password: ******** 
User xxxx logged in.
xxxx <xxxx@org> (xxxx) accessed 2024/03/23
 ... etc

This issue is not present in the Windows build of 4.27.2 (working out-of-the-box) and, according to this post, SSL has been supported since version 4.8.

Switching to Windows or UE5 could mitigate this, but both of these options would be an inconvenience to the team. Would anyone be able to give suggestions for resolving this?

Many thanks.

1 Like

Try to go inside Engine\Source\ThirdParty\OpenSSL and update the library and compile the engine again.

Hi, thanks for your quick response! I was having a look and just noticed that the version of OpenSSL in this dir is higher than the UE4 error message requests:

âžś  OpenSSL pwd
/home/user/Downloads/UnrealEngine-4.27.2-release/Engine/Source/ThirdParty/OpenSSL

âžś  OpenSSL ls -la
total 28
drwxrwxr-x   5 user user 4096 May 17  2023 .
drwxrwxr-x 104 user user 4096 Dec  7  2021 ..
drwxrwxr-x   4 user user 4096 May 17  2023 1.1.1c
drwxrwxr-x   4 user user 4096 May 17  2023 1.1.1k
-rw-rw-r--   1 user user 3244 Dec  7  2021 OpenSSL.Build.cs
-rw-rw-r--   1 user user  637 Dec  7  2021 OpenSSL.tps
drwxrwxr-x   2 user user 4096 May 17  2023 Patches

I have tried chmod -R 777 ./1.1.1c to check it’s not an access error, but I still have the same issue. Would you still recommend upgrading to a higher version of OpenSSL, e.g. 3.x ?

Inside the terminal I am launching UE4 from, I have an extra error message:

LogSourceControl: Error: P4ERROR: Invalid connection to server.
LogSourceControl: Error: Connect to server failed; check $P4PORT.
SSL library must be at least version 1.0.1.

It could be less about OpenSSL, and that the connection vars are not being read properly, though I can’t follow this logic since these vars are set inside of the game engine (below). It also doesn’t work with $P4PORT either set or unset inside of the terminal session.

I was checking Engine\Source\ThirdParty\Perforce\Perforce.Build.cs and the ssl lib is using is inside p4api-2014.1.

So in 4.27.2 the linux part in Perforce.build.cs is
perforce4.27

In Unreal 5 is …
perforce 5.4

so change the line Perforce/p4api-2014.1/ for the one in Unreal 5 and download that folder from a resent version of Unreal source , and check if compile.

Thanks this looks like a good lead.

I have tried the fix you mentioned: copying the library from UE5.3 and changing Perforce.build.cs.

Sadly the library was not compiled with just this fix, I think because the directory include was changed to Include in newer releases of the API. After this, I tried compiling again a few more times. Each time blindly changing a few more variables in the .cs file which seemed like they would matter but haven’t got it working. There is probably a bit of nuance to it, and I don’t have that knowledge :smiling_face_with_tear:.

Just looking for a way to point Unreal at the correct package so it’s compiled and then see if this is the fix.


Steps I’ve done:

Download UE5.3.2, UE4.27.2.

tar -xvf UnrealEngine-5.3.2-release.tar.gz
tar -xvf UnrealEngine-4.27.2-release.tar.gz

Copy the library:

cp -r UnrealEngine-5.3.2-release/Engine/Source/ThirdParty/Perforce/p4api-2018.1/Include/Linux UnrealEngine-4.27.2-release/Engine/Source/ThirdParty/Perforce/p4api-2018.1/Include

Open the file UnrealEngine-4.27.2-release/Engine/Source/ThirdParty/Perforce/Perforce.Build.cs as you said, and change to this:

// ...
}
else if (Target.Platform == UnrealTargetPlatform.Linux)
{
    P4APIPath = Target.UEThirdPartySourceDirectory + "Perforce/p4api-2018.1/";
    LibFolder += "Linux";
    IncludeSuffix += "/Linux";
}
// ...

Run the compile steps:

âžś  UE cp ../Commit.gitdeps.xml UnrealEngine-4.27.2-release/Engine/Build/Commit.gitdeps.xml
âžś  UE cd UnrealEngine-4.27.2-release
âžś  UnrealEngine-4.27.2-release ./Setup.sh
# ...
# Register unreal file types? (Y)
# ...
# No third party libs needed to be built locally

# **********  SUCCESS ****************
# Setup successful.

Then I can see the Library was not compiled:

âžś  UE cd UnrealEngine-4.27.2-release/Engine/Source/ThirdParty/Perforce/p4api-2018.1
âžś p4api-2018.1 ls *
Include:
Linux  Mac  Win32  Win64

Lib:
Mac  Win32  Win64

Let me see what I can do on my custom build. I let you know.

I did everything you did but at compilation time was complaining about “libp4sslstub” so I change the line

For this one…

and it compile without issues.

I didnt try it cause I dont have a linux OS available at the moment but Im assuming it work if compile.

Hi again, thank you for the response. I have tried your newest suggestion + the code fix before, but it’s still not compiling the library on Linux. I tried running GenerateProjectFiles.sh but it’s showing the following:

/home/user/Downloads/UE/UnrealEngine-4.27.2-release/Engine/Source/ThirdParty/Perforce/Perforce.Build.cs: warning: Referenced directory '/home/user/Downloads/UE/UnrealEngine-4.27.2-release/Engine/Source/ThirdParty/Perforce/p4api-2018.1/include/Linux' does not exist.

Thank you again, your patience and support is incredible, but I may start looking towards UE5 to keep the project moving, instead of fixing a niche problem such as this.
If you still have suggestions though, if I’m able I will give them a go on Linux for the posterity of this article and see if we can find a fix :slight_smile:

Then you are not copying the folder from UE5 correctly . Every time you run Setup.sh all files get overwrite .
When you download the Source you dont have all the files until you run Setup.sh. May be you copied just an empty folder from UE5.

Hey again, yes I ran Setup.sh before GenerateProjectFiles.sh, it was just to show that it’s not finding them after the fact.

I am not copying an empty folder from UE5. Do you perhaps mean I should compile UE5, and copy the compiled folder over? I can try but I don’t think that is reliable. Here is a picture from my terminal to show it’s not empty, with Mac dir for comparison:

Again, it is probably some small detail still left here. Maybe it built for you because on Windows filepaths are case-insensitive.

Here is my full file UnrealEngine-4.27.2-release/Engine/Source/ThirdParty/Perforce/Perforce.Build.cs

// Copyright Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;
using System.IO;

public class Perforce : ModuleRules
{
	public Perforce(ReadOnlyTargetRules Target) : base(Target)
	{
		Type = ModuleType.External;

		if (Target.Platform == UnrealTargetPlatform.Win64 || Target.Platform == UnrealTargetPlatform.Win32)
		{
			string Windows_P4APIPath = Target.UEThirdPartySourceDirectory + "Perforce/p4api-2018.1/";

			string PlatformSubdir = Target.Platform.ToString();
			string VisualStudioVersionFolder = "VS" + Target.WindowsPlatform.GetVisualStudioCompilerVersionName();

			string IncludeFolder = Path.Combine(Windows_P4APIPath, "Include", PlatformSubdir, VisualStudioVersionFolder);
			PublicSystemIncludePaths.Add(IncludeFolder);

			string ConfigPath = (Target.Configuration == UnrealTargetConfiguration.Debug && Target.bDebugBuildsActuallyUseDebugCRT) ? "Debug" :"Release";
			string LibFolder = Path.Combine(Windows_P4APIPath, "Lib", PlatformSubdir, VisualStudioVersionFolder, ConfigPath);
			PublicAdditionalLibraries.Add(Path.Combine(LibFolder, "libclient.lib"));
			PublicAdditionalLibraries.Add(Path.Combine(LibFolder, "librpc.lib"));
			PublicAdditionalLibraries.Add(Path.Combine(LibFolder, "libsupp.lib"));
		}
		else
		{
			string LibFolder = "lib/";
			string IncludeSuffix = "";
			string LibPrefix = "";
			string LibPostfixAndExt = ".";
			string P4APIPath = Target.UEThirdPartySourceDirectory + "Perforce/p4api-2015.2/";

			if (Target.Platform == UnrealTargetPlatform.Mac)
			{
				P4APIPath = Target.UEThirdPartySourceDirectory + "Perforce/p4api-2018.1/";
				LibFolder += "mac";
				IncludeSuffix += "/Mac";
			}
			else if (Target.Platform == UnrealTargetPlatform.Linux)
			{
			    P4APIPath = Target.UEThirdPartySourceDirectory + "Perforce/p4api-2018.1/";
			    LibFolder += "Linux";
			    IncludeSuffix += "/Linux";
			}

			LibPrefix = P4APIPath + LibFolder + "/";
			LibPostfixAndExt = ".a";

			PublicSystemIncludePaths.Add(P4APIPath + "include" + IncludeSuffix);
			PublicAdditionalLibraries.Add(LibPrefix + "libclient" + LibPostfixAndExt);

			if (Target.Platform != UnrealTargetPlatform.Win64 && Target.Platform != UnrealTargetPlatform.Mac)
			{
				PrivateDependencyModuleNames.Add("SSL");
			}

			PublicAdditionalLibraries.Add(LibPrefix + "librpc" + LibPostfixAndExt);
			PublicAdditionalLibraries.Add(LibPrefix + "libsupp" + LibPostfixAndExt);
		}
	}
}

Again, after compiling the Linux Lib is not present:

~ UE cp ./Commit.gitdeps.xml UnrealEngine-4.27.2-release/Engine/Build/Commit.gitdeps.xml
~ cd  UnrealEngine-4.27.2-release
~  UnrealEngine-4.27.2-release ./Setup.sh
# ...
# No third party libs needed to be built locally

# **********  SUCCESS ****************
# Setup successful.

~ ls UnrealEngine-4.27.2-release/Engine/Source/ThirdParty/Perforce/p4api-2018.1/Lib
# Mac  Win32  Win64

You are confuse thinking you will create the libs when you compile your engine, but that`s not the case. The libs should be already there before you start compiling.

When you run the UE5 setup.sh you should end up with 2 Folders inside “p4api-2018.1”.

One Include folder (the one you show me) and one Lib folder. Inside Lib folder you have 3 folder one for each platform , Win64, Linux, and Mac.
Those Libs inside Linux is what you need when you compile your engine, UnrealbuildTools will link your perforce binaries to those libs inside that folder.

I see you are only copying the Linux folder, you need to copy the whole “p4api-2018.1” folder.

1
2
3

Compiler is complaining because cant find the libs.

Thanks I am away for easter but will try this after. However those Lib files are not present until I already run Setup.sh, even on UE5:

âžś UE ls UnrealEngine-5.3.2-release/Engine/Source/ThirdParty/Perforce/p4api-2018.1
# Include
âžś cd UnrealEngine-5.3.2-release
âžś UnrealEngine-5.3.2-release ./Setup.sh
# ...
âžś UnrealEngine-5.3.2-release ls Engine/Source/ThirdParty/Perforce/p4api-2018.1
# Include Lib

Apologies I don’t know too much about compilers, does Setup.sh compile the engine? Or are the Lib files just generated by running Setup.sh, and then compiling happens at a later stage, so I can manually inject these Lib files without issues.

Setup.sh just download those libs so you can link them at later stage .