x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Unreal Build Tool error

Good day, have some errors with UBT when try add OpenCV to project. Can somebody explain me probable reasons?

error CS1729: 'UnrealBuildTool.ModuleRules' does not contain a constructor that takes 0 arguments QuestTest D:\Work\VRPal\UEProj\QuestTest\Intermediate\ProjectFiles\UnrealBuildTool 1

error CS0122: 'UnrealBuildTool.BuildConfiguration' is inaccessible due to its protection level QuestTest D:\Work\VRPal\UEProj\QuestTest\Intermediate\ProjectFiles\UnrealBuildTool 1

Product Version: UE 4.19 Preview
Tags:
more ▼

asked Mar 01 '18 at 09:56 AM in C++ Programming

avatar image

Kelt
24 4 5 10

avatar image Atheist91 Mar 01 '18 at 02:03 PM

Did you upgrade your project from some older version of the engine?

avatar image Kelt Mar 01 '18 at 02:23 PM

yes, but i create another project on 4.19, this result repeated.

avatar image Atheist91 Mar 01 '18 at 02:59 PM

I see. Could you show content of your ProjectName.Build.cs file?

avatar image Kelt Mar 01 '18 at 04:23 PM

public class CPlusPlus : ModuleRules { private string ModulePath { get { return ModuleDirectory; } }

 private string ThirdPartyPath
 {
     get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "../ThirdParty/")); }
 }

 public bool LoadOpenCV(TargetInfo Target)
 {
     // Start OpenCV linking here!
     bool isLibrarySupported = false;

     // Create OpenCV Path 
     string OpenCVPath = Path.Combine(ThirdPartyPath, "OpenCV");

     // Get Library Path 
     string LibPath = "";
     bool isdebug = Target.Configuration == UnrealTargetConfiguration.Debug && BuildConfiguration.bDebugBuildsActuallyUseDebugCRT;
     if (Target.Platform == UnrealTargetPlatform.Win64)
     {
         LibPath = Path.Combine(OpenCVPath, "Libraries", "Win64");
         isLibrarySupported = true;
     }
     else
     {
         string Err = string.Format("{0} dedicated server is made to depend on {1}. We want to avoid this, please correct module dependencies.", Target.Platform.ToString(), this.ToString()); System.Console.WriteLine(Err);
     }

     if (isLibrarySupported)
     {
         //Add Include path 
         PublicIncludePaths.AddRange(new string[] { Path.Combine(OpenCVPath, "Includes") });

         // Add Library Path 
         PublicLibraryPaths.Add(LibPath);

         //Add Static Libraries
         PublicAdditionalLibraries.Add("opencv_world320.lib");

         //Add Dynamic Libraries
         PublicDelayLoadDLLs.Add("opencv_world320.dll");
         PublicDelayLoadDLLs.Add("opencv_ffmpeg320_64.dll");
     }

     Definitions.Add(string.Format("WITH_OPENCV_BINDING={0}", isLibrarySupported ? 1 : 0));

     return isLibrarySupported;
 }
avatar image Kelt Mar 01 '18 at 04:27 PM
 public CPlusPlus(ReadOnlyTargetRules Target) : base(Target)
     {
         PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
     
         PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "RHI", "RenderCore", "ShaderCore" });
 
         PrivateDependencyModuleNames.AddRange(new string[] {  });
 
         // Uncomment if you are using Slate UI
         // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
 
         // Uncomment if you are using online features
         // PrivateDependencyModuleNames.Add("OnlineSubsystem");
 
         // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
        // LoadOpenCV(Target);
     }
 
 }
avatar image Atheist91 Mar 02 '18 at 09:22 AM

Is this the only module you have in your project? QuestTest perhaps? It looks error is related to that module

avatar image Kelt Mar 02 '18 at 09:27 AM

some edit

 public QuestTest(TargetInfo Target)

avatar image Kelt Mar 02 '18 at 09:29 AM

UBT not see - BuildConfiguration.bDebugBuildsActuallyUseDebugCRT and constructor for game. I try connect OpenCV to UE4.

avatar image Atheist91 Mar 02 '18 at 09:32 AM

I think you might be missing call to base constructor in constructor of your QuestTest module class (within QuestTest .Build.cs).

What's the parent of that class?

avatar image Kelt Mar 02 '18 at 09:35 AM

Do you mean game constructor with initializtion game modules or C# constructor for build script?

avatar image Atheist91 Mar 02 '18 at 09:38 AM

C# constructor.

avatar image Kelt Mar 02 '18 at 09:38 AM
 #include "QuestTest.h"
 #include "Modules/ModuleManager.h"
 
 IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, QuestTest, "QuestTest" );
 
avatar image Atheist91 Mar 02 '18 at 09:40 AM

I meant constructor within QuestTest.Build.cs, sorry for not specifying that. :p

avatar image Kelt Mar 02 '18 at 09:42 AM
 //Constructor dependencies
     public QuestTest(TargetInfo Target)//(ReadOnlyTargetRules Target) : base(Target)
     {
         PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
     
         PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "RHI", "RenderCore", "ShaderCore" });
 
         //PrivateDependencyModuleNames.AddRange(new string[] {  });
 
         LoadOpenCV(Target);
 
         // Uncomment if you are using Slate UI
         // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
 
         // Uncomment if you are using online features
         // PrivateDependencyModuleNames.Add("OnlineSubsystem");
 
         // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
     }
avatar image Kelt Mar 02 '18 at 09:44 AM

It's constructor in *.Build.cs

avatar image GIGA-Money Mar 01 '18 at 03:50 PM

Well here are the error code docs cs1729: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs1729

cs0122 https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs0122

the first error seams like some c++ object you made doesn't have a constructor. see the rule of 3/5/0 http://en.cppreference.com/w/cpp/language/rule_of_three

I am thinking that the location to which things need to be compiled (the project location) might have its permissions on say read only - or your user (window's user) might not have permission to the file.

avatar image Kelt Mar 01 '18 at 04:26 PM

Some interesting, that i use tutorial for OpenCV and not work.

avatar image Kelt Mar 01 '18 at 04:36 PM

And this is not C++ compiler.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

From what I know, in UE 4.16 engine switched from using ReadOnlyTargetRules from TargetInfo in constructor of your C# modules. In newer version you also have to call base contructor and pass that target(ReadOnlyTargetRules) there.

So, here's modified code of yours that should work:

Constructor:

 // Constructor dependencies
 public QuestTest(ReadOnlyTargetRules Target) : base(Target) // changed
 {
     PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
 
     PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "RHI", "RenderCore", "ShaderCore" });
 
     //PrivateDependencyModuleNames.AddRange(new string[] {  });
 
     LoadOpenCV(Target);
 
     // Uncomment if you are using Slate UI
     // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
 
     // Uncomment if you are using online features
     // PrivateDependencyModuleNames.Add("OnlineSubsystem");
 
     // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
 }

And LoadOpenCS function:

 public bool LoadOpenCV(ReadOnlyTargetRules Target)  // changed
 {
     // Start OpenCV linking here!
     bool isLibrarySupported = false;
 
     // Create OpenCV Path 
     string OpenCVPath = Path.Combine(ThirdPartyPath, "OpenCV");
 
     // Get Library Path 
     string LibPath = "";
     bool isdebug = Target.Configuration == UnrealTargetConfiguration.Debug && Target.bDebugBuildsActuallyUseDebugCRT;  // changed
     if (Target.Platform == UnrealTargetPlatform.Win64)
     {
         LibPath = Path.Combine(OpenCVPath, "Libraries", "Win64");
         isLibrarySupported = true;
     }
     else
     {
         string Err = string.Format("{0} dedicated server is made to depend on {1}. We want to avoid this, please correct module dependencies.", Target.Platform.ToString(), this.ToString()); System.Console.WriteLine(Err);
     }
 
     if (isLibrarySupported)
     {
         //Add Include path 
         PublicIncludePaths.AddRange(new string[] { Path.Combine(OpenCVPath, "Includes") });
 
         // Add Library Path 
         PublicLibraryPaths.Add(LibPath);
 
         //Add Static Libraries
         PublicAdditionalLibraries.Add("opencv_world320.lib");
 
         //Add Dynamic Libraries
         PublicDelayLoadDLLs.Add("opencv_world320.dll");
         PublicDelayLoadDLLs.Add("opencv_ffmpeg320_64.dll");
     }
 
     Definitions.Add(string.Format("WITH_OPENCV_BINDING={0}", isLibrarySupported ? 1 : 0));
 
     return isLibrarySupported;
 }

In case you'd wonder, changed lines (3) are marked with // changed comment. Hope this helps.

more ▼

answered Mar 02 '18 at 10:37 AM

avatar image

Atheist91
1.2k 18 23 40

avatar image Atheist91 Mar 02 '18 at 10:58 AM

Fixed compilation error related to bDebugBuildsActuallyUseDebugCRT property.

avatar image Kelt Mar 02 '18 at 11:34 AM

Yes, i test it, all work. Thanks. Do you use any helpers for cs compilator, because my VS not show functions declarated for UBT?

avatar image Atheist91 Mar 02 '18 at 11:37 AM

I'm glad that it works :]

I use VAX but it doesn't help with that on its own. When you have engine built from source code, it's added to solution with your project. Then you can search for symbols from engine and programs like UBT etc.

Cheers.

avatar image Kelt Mar 02 '18 at 11:43 AM

Big thanks, already start learn how to add lib and dll functions to ue.) Best wishes, Kelt.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question