[Help] Questions when I construct my own Console-App in my project-folder.

Here is my work’s folder architecture:



Z:\
-    [UnrealEngine_NF]
-          [Engine]
-          [Samples]
-          [Templates]
-          ....blablabla....
-    [UnrealProjects]
-          [ProjectFeudal]
-                [Content]
-                [Source]
-                    [Programs]
-                              [FeudalConsole]
-                                    [Private]
-                                          FeudalConsole.cpp
-                                          FeudalConsole.h
-                                    FeudalConsole.build.cs
-                                    FeudalConsole.Target.cs
-                    ProjectFeudal.Target.cs
-                ProjectFeudal.uproject


Where FeudalConsole is copy from Engine’s Program/BlankProgram. But I changed it’s Target name and Module name.

Here is the compile error ( VS 2013 Communicate )



1>------ Build started: Project: FeudalConsole, Configuration: Development_Program x64 ------
......
1>Z:\UnrealProjects\ProjectFeudal\Source\Programs\FeudalConsole\Private\FeudalConsole.cpp(6): fatal error C1083: Cannot open include file: 'RequiredProgramMainCPPInclude.h': No such file or directory
......


I found the file is in “Z:\UnrealEngine_NF\Engine\Source\Runtime\Launch\Public\RequiredProgramMainCPPInclude.h”.
But my Module Rule has already locate this location… by relative path …



public class FeudalConsole : ModuleRules
{
  public FeudalConsole(TargetInfo Target)
 {
        PublicIncludePaths.Add("Runtime/Launch/Public");
        PrivateIncludePaths.Add("Runtime/Launch/Private");  // For LaunchEngineLoop.cpp include
        PrivateDependencyModuleNames.Add("Core");
        PrivateDependencyModuleNames.Add("Projects");
 }
}


So I try to use absolutely path here:



public class FeudalConsole : ModuleRules
{
  public FeudalConsole(TargetInfo Target)
 {
        string MyUnrealPath = "Z:/UnrealEngine_NF/Engine/Source/";
        PublicIncludePaths.Add(MyUnrealPath + "Runtime/Launch/Public");
        PrivateIncludePaths.Add(MyUnrealPath + "Runtime/Launch/Private");  // For LaunchEngineLoop.cpp include
        PrivateDependencyModuleNames.Add("Core");
        PrivateDependencyModuleNames.Add("Projects");
 }
}


Then the project was successfully compiled. And generate FeudalConsole.exe in my project’s Binaries/Win64 ( “Z:\UnrealProjects\ProjectFeudal\Binaries\Win64” )

But If I run this .exe it will have some runtime error:
“Failed to determine engine directory: Defaulting to …/…/Engine”
I copy it to Z:\UnrealEngine_NF\Engine\Binaries\Win64
Then everything is ok… It runs successfully.

So there are two questions:
1, I don’t want to write absolute pathes in this Module Rule. If do so, I cannot work with my partners. (They may not place their work-folder in Z:)
2, I found the FeudalConsole.vcxproj’s OutputPath is “<NMakeOutput>Z:\UnrealEngine_NF\Engine\Binaries\Win64\FeudalConsole.exe</NMakeOutput>”,
but it generate FeudalConsole.exe in “Z:\UnrealProjects\ProjectFeudal\Binaries\Win64\FeudalConsole.exe” ? Why?

Thanks. :slight_smile:

Thanks…
Maybe I need to try to debug the UBT to see how to fix this problem.

Hi

I think you need to change:



PublicIncludePaths.Add("Runtime/Launch/Public");


to:



PrivateIncludePaths.Add("Runtime/Launch/Public");


since the source file including “RequiredProgramMainCPPInclude.h” is in a Private sub-folder.
At least that is what I had to do.
Would be great if someone from Epic can comment on this?

The following blog post has an excellent description of the what and why:
http://dmitry-yanovsky.com/2015/08/unreal-engine-4-build-file-demystified/

Hope this works for you :wink:

Turns out I am running into exactly the same problem now.

I probably thought I was compiling successfully when I wasn’t: Sometimes Visual Studio reports that it is building your target (e.g. console app) but no built binary appears.

However, this build/folder layout as used by OP seems to be the only way to get a console application built side-by-side with user game modules and to get it built outside of the UnrealEngine source tree?

Still learning how to use UBT and its configuration properly it seems.