Worst-case scenario: the UEd Goblin wipes the map and burns down your house.

Legacy:Native Coding On Linux

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

Here's how I (almost) managed to compile native code for Linux UT. WARNING: this does not work for me, the final result segfaults - but then again, linux ut likes to segfault anyway.

Requirements: you need both a Linux and Windows systems, with latest UT and source distribution. I find it easier to use two machines, but if you can, you can try wine, Plex86 or (last resort) dual-boot. In this text I'll assume you have two machines, if you don't, make the necessary mental adjustments.

I couldn't compile successfully using Epic's source distribution; there were some problems with the Un*.h header files. I fetched over UnGnuG.h from OpenUT and fixed a few things, my file is at UnGnuG.h if you need it. I believe you could try compiling with the full OpenUT sources instead of the source distribution, but it would probably segfault if your UT binary is not built from OpenUT (some variables are double in one version and float in the other, for example).

I'm using the tutorial linked from Native_Coding, which builds a mod named Hazard.

  1. first, create the directory tree as described in the tutorial, in both machines. Alternatively, use some form of file sharing to have a single source tree for both; in this case disregard all "copy over" instructions
  1. create the .uc file in one machine and copy it over to the other one
  1. run "ucc make" on the *Windows* machine
  1. copy over the resulting HazardClasses.h to Linux
  1. create the source files in Src
  1. on a shell prompt, go to Hazard/Src
  1. compile: gcc -c -O2 -Werror -fomit-frame-pointer -mpentium -D_REENTRANT -o Hazard.o -I ../../Core/Inc -I ../../Engine/Inc -I ../Inc -D __LINUX_X86__ -D__STATIC_LINK=0 -fno-for-scope hzTest.cpp
  1. link: ld -shared -o ../../System/Hazard.so Hazard.o ../../System/Core.so ../../System/Engine.so
  1. fabricate the .dll file on Windows like the tutorial says, then run "ucc make" (on Windows) again to bind the .u file to the dll.
  1. get the bound .u file to Linux.
  1. test it as the tutorial says. Should work. For me it segfaults :-(

Foxpaw: Epic says that native coding under Linux doesn't work and to my knowledge they don't plan to fix it it anytime soon. That may be why it's having a segmentation fault.