Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac build issue, UE 4.16, Xcode: Expected *.h to be first header included #66

Open
bcbrock opened this issue Jun 20, 2017 · 5 comments
Open

Comments

@bcbrock
Copy link

bcbrock commented Jun 20, 2017

I'm building the UnrealEngine 4.16.1 itself and the UnrealCV master source code together from XCode on Mac OS 10.12.2. It seems that all of the UnrealCV headers get a compile error in this environment:

Parsing headers for UE4Editor
  Running UnrealHeaderTool UE4Editor "/Users/bcbrock/UnrealEngine/Engine/Intermediate/Build/Mac/UE4Editor/Development/UE4Editor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors
Reflection code generated for UE4Editor in 10.8587898 seconds
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/CaptureManager.cpp(1): error: Expected CaptureManager.h to be first header included.
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/CommandDispatcher.cpp(1): error: Expected CommandDispatcher.h to be first header included.
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/ConsoleHelper.cpp(1): error: Expected ConsoleHelper.h to be first header included.
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/ExecStatus.cpp(1): error: Expected ExecStatus.h to be first header included.
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/GTCaptureComponent.cpp(1): error: Expected GTCaptureComponent.h to be first header included.
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/ObjectPainter.cpp(1): error: Expected ObjectPainter.h to be first header included.
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/PlayerViewMode.cpp(1): error: Expected PlayerViewMode.h to be first header included.
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/ScreenCapture.cpp(1): error: Expected ScreenCapture.h to be first header included.
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/ServerConfig.cpp(1): error: Expected ServerConfig.h to be first header included.
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/TcpServer.cpp(1): error: Expected TcpServer.h to be first header included.
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/UE4CVGameMode.cpp(1): error: Expected UE4CVGameMode.h to be first header included.
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/UE4CVServer.cpp(1): error: Expected UE4CVServer.h to be first header included.
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/ViewMode.cpp(1): error: Expected ViewMode.h to be first header included.
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/Commands/ActionHandler.cpp(1): error: Expected ActionHandler.h to be first header included.
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/Commands/AliasHandler.cpp(1): error: Expected AliasHandler.h to be first header included.
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/Commands/CameraHandler.cpp(1): error: Expected CameraHandler.h to be first header included.
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/Commands/ObjectHandler.cpp(1): error: Expected ObjectHandler.h to be first header included.
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/Commands/PluginHandler.cpp(1): error: Expected PluginHandler.h to be first header included.
/Users/bcbrock/UnrealEngine/Engine/Plugins/UnrealCV/Source/UnrealCV/Private/libs/cnpy.cpp(1): error: Expected cnpy.h to be first header included.
Build canceled.
Command /Users/bcbrock/UnrealEngine/Engine/Build/BatchFiles/Mac/Build.sh failed with exit code 1

This error is apparently due to a recent UnrealEngine feature called "Insert What You Use" (IWYU). A quick fix is to modify UnrealCV.Build.cs:

diff --git a/Source/UnrealCV/UnrealCV.Build.cs b/Source/UnrealCV/UnrealCV.Build.cs
index 1a395ee..ebf01f2 100644
--- a/Source/UnrealCV/UnrealCV.Build.cs
+++ b/Source/UnrealCV/UnrealCV.Build.cs
@@ -7,6 +7,8 @@ namespace UnrealBuildTool.Rules
 	{
 		public UnrealCV(TargetInfo Target)
 		{
+			bEnforceIWYU = false;
+
 			// This trick is from https://answers.unrealengine.com/questions/258689/how-to-include-private-header-files-of-other-modul.html
 			string EnginePath = Path.GetFullPath(BuildConfiguration.RelativeEnginePath);

Interestingly, this error does not occur when I build the UnrealCV plugin with build.sh, only when built under XCode.

@qiuwch
Copy link
Member

qiuwch commented Jun 21, 2017

Cooool. Thanks for reporting this.

Do you want to make a pull request to update the Build.cs, so that github can track your contribution?
Or I can also do that.

@bcbrock
Copy link
Author

bcbrock commented Jun 21, 2017

Please feel free to make this change yourself. Technically I would be required to go through a formal legal process if I do anything beyond opening issues :-)

@qiuwch
Copy link
Member

qiuwch commented Jun 21, 2017

I see, I did not expect this can cause a trouble for you. I will do it. Thanks.

@qiuwch
Copy link
Member

qiuwch commented Jun 21, 2017

I am traveling now and will update it when I am back. I need to do a little testing to make sure it won't break the compilation of other UE4 versions.

@doublerebel
Copy link

Related: #55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants