proletariatgames / unreal.hx

Unreal.hx: Haxe Integration for Unreal
MIT License
425 stars 43 forks source link

Setting up Haxe with Unreal #45

Closed joelutting closed 8 years ago

joelutting commented 8 years ago

I've been working on this for several hours but having lots of problems and cant find clear docs on this. Tried to setup the platformer, but when I tried opening unreal it tired to compiled several DLLs, but then it said it could not compile and I should compile manually.

So I tried the ant build method but kept getting errors. The last of which was this; E:\Unreal Projects\PlatformerGame>ant build Buildfile: E:\Unreal Projects\PlatformerGame\build.xml

init-plugin:

BUILD FAILED E:\Unreal Projects\PlatformerGame\build.xml:134: Execute failed: java.io.IOException: Cannot run program "E:\Unreal Projects\PlatformerGame\haxe" (in directory "E:\Unreal Projects\PlatformerGame\Plugins\UnrealHx"): CreateProcess error=5, Access is denied at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at java.lang.Runtime.exec(Runtime.java:620) at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58) at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:426) at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:440) at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:629) etc...

I've tried several things over the hours but nothing has worked.

I also tried setting up unreal.hx in unreal, but the instructions are unclear to me; Port your main Build.cs module to Build.hx and make sure it extends HaxeModuleRules

not sure how to do this step. Is there anything more? a video showing steps?

waneck commented 8 years ago

Hi there. First of all, do you have haxe setup? Have you ran haxelib install hxcpp and haxelib install hxcs ? I haven't tested the ant build scripts on Windows, but I've just looked into them and they should work on Windows as well, if haxe is on the path

joelutting commented 8 years ago

yes haxe is installed I also have haxedevelop and hae setup and ran some small examples. I installed those 2 libs while trying to fix the problems.

So this hasn't been tested on windows before?

Tried some more things, but still getting same error.

haxe runs from command prompt so I assume its in the path; E:\Unreal Projects\PlatformerGame>haxe Haxe Compiler 3.2.1 - (C)2005-2015 Haxe Foundation Usage : haxe.exe -main [-swf|-js|-neko|-php|-cpp|-as3] [options] Options : -cp : add a directory to find source files

why would it be getting 'access denied' ?

joelutting commented 8 years ago

Trying everything to get this working...

  1. removed the init plugin part of build.xml
  2. got complaint about missing UE4 variable - so I set that up.
  3. had to change path to point to jdk and not jre as missing tools.jar error
  4. final error now (but I'm not sure the init plugin error is solved, though I manually ran the haxe InitPlugin.hx command and it seemed to work)

E:\Unreal Projects\PlatformerGame>ant build Buildfile: E:\Unreal Projects\PlatformerGame\build.xml

build: [exec] Creating makefile for PlatformerGameEditor (no existing makefile) [exec] ERROR: Couldn't find target rules file for target 'PlatformerGameEditor' in rules assembly 'UE4Rules, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. [exec] Location: E:\UnrealEngine\Epic Games\4.11\Engine\Intermediate\Build\BuildRules\UE4Rules.dll [exec] Target rules found: [exec] UE4Editor - E:\UnrealEngine\Epic Games\4.11\Engine\Source\UE4Editor.Target.cs [exec] UE4Game - E:\UnrealEngine\Epic Games\4.11\Engine\Source\UE4Game.Target.cs [exec] UnrealHeaderTool - E:\UnrealEngine\Epic Games\4.11\Engine\Source\Programs\UnrealHeaderTool\UnrealHeaderTool.Target.cs [exec]

BUILD FAILED E:\Unreal Projects\PlatformerGame\build.xml:142: The following error occurred while executing this line: E:\Unreal Projects\PlatformerGame\build.xml:73: exec returned: 5

Total time: 1 second

waneck commented 8 years ago

Unreal.hx itself has been tested with Windows a lot - it's in fact the main platform we're targeting. The example code HaxePlatformerGame's build script haven't been tested outside my main development platform, which is linux.

I think there is a problem with the init-plugin target (on which build depends). If you run haxe init-plugin.hxml yourself, you might be able to delete that part from build.xml like you did - and it should work. That Couldn't find target rules file for target 'PlatformerGameEditor' in rules assembly seems to indicate that haxe init-plugin.hxml wasn't done at first. Was it? You can check if a file at path HaxePlatformerGame/PlatformerGame/Source/PlatformerGame/PlatformerGame.Build.cs exists - because that's one of the things that init-plugin.hxml does.

Also, you're using Haxe version 3.2.1, while Haxe 3.3 is required for the latest unreal.hx.

Please let me know if you can make this work - I'll try to test this on Windows and report back the fixes

joelutting commented 8 years ago

Some progress and I feel stupid! I had an old version of haxe installer and didn't realise - I clicked on the wrong installer. With 3.3 things went further, but still getting errors...

  1. I followed the instructions from scratch and tried opening in unreal directly - this got a lot further then before compiling for a while...but then it ended saying 'could not compile, try manually'

The log got about this far;

(I might not have caught the end, the log closed when it failed)

So I went the manual route, and errors again, so I did the "haxe init-plugin.hxml" manually in plugins/unrealhx - which seemed to work without errors, and then removed the init-plugin target from the build.xml, and then ant build again and got this;

E:\Unreal Projects\HaxePlatformerGame\PlatformerGame>ant build Buildfile: E:\Unreal Projects\HaxePlatformerGame\PlatformerGame\build.xml

build: [exec] Creating makefile for PlatformerGameEditor (no existing makefile) [exec] ERROR: Couldn't find target rules file for target 'PlatformerGameEditor' in rules assembly 'UE4Rules, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. [exec] Location: E:\UnrealEngine\Epic Games\4.11\Engine\Intermediate\Build\BuildRules\UE4Rules.dll [exec] Target rules found: [exec] UE4Editor - E:\UnrealEngine\Epic Games\4.11\Engine\Source\UE4Editor.Target.cs [exec] UE4Game - E:\UnrealEngine\Epic Games\4.11\Engine\Source\UE4Game.Target.cs [exec] UnrealHeaderTool - E:\UnrealEngine\Epic Games\4.11\Engine\Source\Programs\UnrealHeaderTool\UnrealHeaderTool.Target.cs [exec]

BUILD FAILED E:\Unreal Projects\HaxePlatformerGame\PlatformerGame\build.xml:135: The following error occurred while executing this line: E:\Unreal Projects\HaxePlatformerGame\PlatformerGame\build.xml:73: exec returned: 5

Total time: 1 second

this is line 73;

joelutting commented 8 years ago

Also - without removing the init-plugin target it was getting this still;

E:\Unreal Projects\HaxePlatformerGame\PlatformerGame>ant build Buildfile: E:\Unreal Projects\HaxePlatformerGame\PlatformerGame\build.xml

init-plugin:

BUILD FAILED E:\Unreal Projects\HaxePlatformerGame\PlatformerGame\build.xml:134: Execute failed: java.io.IOException: Cannot run program "E:\Unreal Projects\HaxePlatformerGame\PlatformerGame\haxe" (in directory "E:\Unreal Projects\HaxePlatformerGame\PlatformerGame\Plugins\UnrealHx"): CreateProcess error=5, Access is denied at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at java.lang.Runtime.exec(Runtime.java:620) at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58) at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:426) at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:440) at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:629) at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:670) at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:496) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293) ...

waneck commented 8 years ago

Hey there. I've just updated the ant build script to fix that init-plugin issue. I've tested with windows, and got this part working:

C:\dev\HaxePlatformerGame\PlatformerGame>SET UE4=C:\Program Files (x86)\Epic Games\4.11
C:\dev\HaxePlatformerGame\PlatformerGame>ant build
Unable to locate tools.jar. Expected to find it in C:\Program Files (x86)\Java\jre1.8.0_91\lib\tools.jar
Buildfile: C:\dev\HaxePlatformerGame\PlatformerGame\build.xml

init-plugin:
     [exec] InitPlugin.hx:22: Inferring project location...
     [exec] InitPlugin.hx:13: Game location: ../../PlatformerGame.uproject
     [exec] InitPlugin.hx:48: Updating game project...
     [exec] InitPlugin.hx:50: Updating game module...
     [exec] InitPlugin.hx:147: Building BuildTool...
     [exec] InitPlugin.hx:18: Project update done.

build:
     [exec] Performing full C++ include scan (building a new target)
     [exec] Creating makefile for PlatformerGameEditor (no existing makefile)
     [exec] InitPlugin.hx:48: Updating game project...
     [exec] InitPlugin.hx:50: Updating game module...
     [exec] haxe -version
     [exec] HaxeCompiler: 3.3.0
     [exec] HaxeModuleRules.hx:204: baking externs
... snip ...
     [exec] haxe --cwd C:\dev\HaxePlatformerGame\PlatformerGame\Haxe arguments.hxml -cp C:\dev\HaxePlatformerGame\PlatformerGame/Haxe/Generated/Externs_Editor -cp C:\dev\HaxePlatformerGame\PlatformerGame\Plugins\UnrealHx/Haxe/Static -cp C:\dev\HaxePlatformerGame\PlatformerGame/Haxe/Static -cp C:\dev\HaxePlatformerGame\PlatformerGame/Haxe/Scripts -main UnrealCppia -D cppia -D ustatic_target=C:\dev\HaxePlatformerGame\PlatformerGame/Intermediate/Haxe/Win64-Development-Editor/Static/Built -cpp C:\dev\HaxePlatformerGame\PlatformerGame/Binaries/Haxe/game.cppia --macro ue4hx.internal.CreateCppia.run(["C:/dev/HaxePlatformerGame/PlatformerGame/Haxe/Static"], ["C:/dev/HaxePlatformerGame/PlatformerGame/Haxe/Scripts"],null) -debug -D WITH_EDITOR -D BUILDTOOL_VERSION_LEVEL=4
     [exec] Parsing headers for PlatformerGameEditor
     [exec]   Running UnrealHeaderTool "C:\dev\HaxePlatformerGame\PlatformerGame\PlatformerGame.uproject" "C:\dev\HaxePlatformerGame\PlatformerGame\Intermediate\Build\Win64\PlatformerGameEditor\Development\UnrealHeaderTool.manifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
     [exec] Reflection code generated for PlatformerGameEditor in 12.0791603 seconds

However, when compiling until the end, I got the following error:

     [exec] Performing 28 actions (2 in parallel)
     [exec] PCH.PlatformerGameLoadingScreen.h.cpp
     [exec] PCH.PlatformerGame.h.cpp
     [exec] FootIKRuntime.generated.cpp
     [exec] [6/28] Resource PCLaunch.rc
     [exec] [7/28] Resource ModuleVersionResource.rc.inl
     [exec] [8/28] Resource PCLaunch.rc
     [exec] [9/28] Resource ModuleVersionResource.rc.inl
     [exec] [10/28] Link UE4Editor-FootIKRuntime.dll
     [exec] [11/28] Link UE4Editor-PlatformerGameLoadingScreen.dll
     [exec]    Creating library C:\dev\HaxePlatformerGame\PlatformerGame\Plugins\FootIK\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-FootIKRuntime.lib and object C:\dev\HaxePlatformerGame\PlatformerGame\Plugins\FootIK\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-FootIKRuntime.exp
     [exec]    Creating library C:\dev\HaxePlatformerGame\PlatformerGame\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-PlatformerGameLoadingScreen.lib and object C:\dev\HaxePlatformerGame\PlatformerGame\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-PlatformerGameLoadingScreen.exp
     [exec] Module.FootIKRuntime.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class TBaseDelegate<class FFixedUObjectArray *> & __cdecl FCoreDelegates::GetObjectArrayForDebugVisualizersDelegate(void)" (__imp_?GetObjectArrayForDebugVisualizersDelegate@FCoreDelegates@@SAAEAV?$TBaseDelegate@PEAVFFixedUObjectArray@@$$$V@@XZ) referenced in function "void __cdecl `dynamic initializer for 'GObjectArrayForDebugVisualizers''(void)" (??__EGObjectArrayForDebugVisualizers@@YAXXZ)
     [exec] PlatformerGameLoadingScreen.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class TBaseDelegate<class FFixedUObjectArray *> & __cdecl FCoreDelegates::GetObjectArrayForDebugVisualizersDelegate(void)" (__imp_?GetObjectArrayForDebugVisualizersDelegate@FCoreDelegates@@SAAEAV?$TBaseDelegate@PEAVFFixedUObjectArray@@$$$V@@XZ) referenced in function "void __cdecl `dynamic initializer for 'GObjectArrayForDebugVisualizers''(void)" (??__EGObjectArrayForDebugVisualizers@@YAXXZ)
     [exec] C:\dev\HaxePlatformerGame\PlatformerGame\Plugins\FootIK\Binaries\Win64\UE4Editor-FootIKRuntime.dll : fatal error LNK1120: 1 unresolved externals
     [exec] C:\dev\HaxePlatformerGame\PlatformerGame\Binaries\Win64\UE4Editor-PlatformerGameLoadingScreen.dll : fatal error LNK1120: 1 unresolved externals

As the log shows, there was an error while linking FootIKRuntime, which isn't Haxe code. Some googling got me to https://answers.unrealengine.com/questions/226424/c-error-linking-shootergame-sample.html - it seems that Visual Studio 2015 is needed to get this to work. I haven't got the time to update my VIsual Studio, but can you check if this will fix your issue?

Also make sure you're on UE 4.11 and Haxe 3.3.0!

joelutting commented 8 years ago

Works! I was using Haxe 3.3 and UE 4.11, but I had visual studio 2013. I installed 2015, but opening directly in UE failed to compile again, but the ant build worked, and I am able to start the game.

Excellent, thanks a lot.

waneck commented 8 years ago

That's great. I've added a notice about VS 2015 on HaxePlatformGame

krupin-maxim commented 8 years ago

I found a bug in Windows. Project path containes a space "C:\Users\T.Buglov\Documents\Unreal Projects\GameProjectHaxe". So init-plugin generates wrong "gen-build-module-rules.hxml" with bad target section. Finally, I have error [exec] ERROR: Couldn't find target rules file for target 'GameProjectHaxeEditor' in rules assembly 'UE4Rules, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

Other path without spaces "C:\Users\T.Buglov\Documents\UnrealProjects\GameProjectHaxe" works fine.

waneck commented 8 years ago

Thanks! I've opened a separate issue about it: #48