[STICKY] How to Compile UOX3 under Linux/macOS

Want to discuss changes to the UOX3 source code? Got a code-snippet you'd like to post? Anything related to coding/programming goes here!
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

How to Compile UOX3 under Linux/macOS

Post by Xuri »

Step 1: Clone the UOX3 Git Repository
Using git and Terminal
First step, open a new terminal and enter the following commands:
  1. (Linux) sudo apt install git - This will install git if not already installed (Ubuntu/Debian-based Linux variants). If you're using a non-Debian flavour of Linux, use the default package manager that comes with it to install git instead.
  2. (macOS) xcode-select --install - This will install git if not already installed, along with required make and gcc tools
  3. [color=#BF0000]git clone https://github.com/UOX3DevTeam/UOX3.git[/color] - This will clone the stable branch of the UOX3 git repository into a subdirectory of the current directory you're in, named UOX3. The latest verified compatible version of SpiderMonkey (1.7) is also included.
  4. Continue to next post for Step 2 - Compiling UOX3!
Bonus: If you'd rather grab another branch of the git repository, like the develop branch where most updates get pushed first before being merged into the master branch, you can use the following command *after* completing the previous step: git checkout develop

(macOS Alternative) - Using GitHub Desktop
  • Download and install the macOS version of GitHub Desktop.
  • Run GitHub Desktop and click File->Clone Repository from the menu.
  • Click the URL tab, enter https://github.com/UOX3DevTeam/UOX3.git, then provide a local path for where you want the UOX3 git repository cloned on your drive.
  • Hit the Clone button!
Last edited by Xuri on Thu Apr 20, 2006 10:53 pm, edited 3 times in total.
-= Ho Eyo He Hum =-
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Step 2: Compiling UOX3 (on Linux/macOS)
You'll need a couple tools before you can compile UOX3 on Linux, like GNU Make (4.2.1 or higher recommended) and gcc. Install these through your favourite package manager or through your flavour of Linux' variant of the following terminal command (specific to Debian/Ubuntu Linux flavours):
  • sudo apt install build-essential (Linux only, macOS already got these through toolset installed in previous post)
Once these tools are in place, navigate to the UOX3 project directory in your terminal and execute the following commands from the project's root directory, in order:
  • chmod +x automake.sh - Makes the automake.sh bash script executable.
  • ./automake.sh - First compiles the SpiderMonkey JS library bundled with UOX3, then compiles the actual UOX3 build, before copying the compiled binary to the root UOX3 project directory.
Once this process is done, you will find the compiled uox3 binary in the root UOX3 directory. You can copy this binary to the directory you intend to run your UOX3 shard from, along with all the files and folders contained in the UOX3/data subdirectory.

It is recommended to run your UOX3 shard from a separate, dedicated directory instead of the data directory in your local UOX3 git repository, to avoid potential git conflicts and accidental overwrites when pulling updates to UOX3 from GitHub in the future.

Once you have all the files in place, you can follow the regular steps listed under Installation and Setup > Configuring Your UOX3 Shard to finish your UOX3 setup.

(Optional) Manual Instructions
If you don't wish to rely on the automake.sh script, but want control over the process yourself, follow these steps (same as what automake.sh does):
  • cd spidermonkey
  • make -f Makefile.ref DEFINES=-DHAVE_VA_LIST_AS_ARRAY CC=gcc
    Linux
    • ar -r libjs32.a Linux_All_DBG.OBJ/*.o
    • cp Linux_All_DBG.OBJ/jsautocfg.h ./
    macOS
    • ar rcs libjs32.a Darwin_DBG.OBJ/*.o
    • cp Darwin_DBG.OBJ/jsautocfg.h ./
  • cd ../source
  • make
-= Ho Eyo He Hum =-
xir
UOX3 Neophyte
Posts: 47
Joined: Mon Aug 23, 2004 2:59 pm
Has thanked: 0
Been thanked: 0

Post by xir »

This is how I got mine working.
Suppose you have both the uox3 and js source checked out from CVS.
I put my js folder where the uox3 source was but you can change the paths if you like.

Go into the js/src directory and do
gmake -f Makefile.ref

It should now compile.

If you are in linux the directory Linux_All_DBG.OBJ will contain both the compiled library and the jsautocfg.h file which it customises. So copy the jsautocfg.h into the directory one up so all the header files are together

cp jsautocfg.h ../

In UOX3 main directory you need this file which you will call Makefile. The other makefile with autogen.sh I couldn't get to work. Make sure to modify the paths to your js library in the Makefile. You should probably replace the jsapi.h in the uox3 directory with the new one from the js/src/ directory so they are consistant.

The binary uox3 should be in the folder now.
You should probably download the all-in-one uox3 from the main site and copy the uox3 binary into that and change the ini settings. I had problems running it, especially with the filepaths in the ini file. Anyways good luck.

Code: Select all

PROG = uox3
RM = rm -f
CC = g++
JSHEADERS = js/src
JSLIB = js/src/Linux_All_DBG.OBJ/libjs.so
LDFLAGS = -lpthread $(JSLIB)
OBJS = \
    ai.o \
    archive.o\
    boats.o \
    books.o \
    cAccountClass.o \
    calcfuncs.o \
    cBaseobject.o \
    cChar.o \
    cConsole.o \
    cDice.o \
    cGuild.o \
    CGump.o \
    cHTMLSystem.o \
    cItem.o \
    CJSMapping.o \
    cmdtable.o \
    cMultiObj.o \
    combat.o \
    commands.o \
    CPacketReceive.o \
    CPacketSend.o \
    cPlayerAction.o \
    cRaces.o \
    CResponse.o \
    cScript.o \
    cServerData.o \
    cServerDefinitions.o \
    cSocket.o \
    cSpawnRegion.o \
    cThreadQueue.o \
    cVersionClass.o \
    cWeather.o \
    Dictionary.o \
    dist.o \
    door.o \
    effect.o \
    fileio.o \
    findfuncs.o \
    globals.o \
    gumps.o \
    house.o \
    items.o \
    jail.o \
    JSEncapsulate.o \
    lineofsight.o \
    magic.o \
    mapstuff.o \
    movement.o \
    msgboard.o \
    network.o \
    npcs.o \
    ObjectFactory.o \
    pcmanage.o \
    quantityfuncs.o \
    queue.o \
    regions.o \
    scriptc.o \
    SEFunctions.o \
    skills.o \
    sound.o \
    speech.o \
    ssection.o \
    targeting.o \
    teffect.o \
    threadsafeobject.o \
    townregion.o \
    trade.o \
    uox3.o \
    UOXJSMethods.o \
    UOXJSPropertyFuncs.o \
    ustring.o \
    vendor.o \
    weight.o \
    wholist.o \
    worldmain.o

CFLAGS = -Wall -I$(JSHEADERS)

$(PROG): $(OBJS)
    $(CC) $(CFLAGS) $(LDFLAGS) -o $(PROG) $(OBJS) $(LDFLAGS)

.cpp.o: $(PROG).h
    $(CC)   $(CFLAGS) -c -g $<

clean:
    $(RM) a.out core *.o *.obj $(PROG)
lingo
UOX3 Novice
Posts: 55
Joined: Thu Jul 07, 2005 12:26 pm
Location: Taipei, Taiwan
Has thanked: 0
Been thanked: 0

Post by lingo »

I think the correct cvs command is

cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/openuo co -P projects/uox3/source

instead of

cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/openuo -P projects/uox3/source

but

cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/openuo co -P projects/uox3/source

will work better because we are downloading with compression.

the same for the mozilla js source.

Edit:
There is extra problem on the mozilla check out instruction

cvs -d: :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot -P mozilla/js/src

it should not be 'cvs -d: :pserver', but 'cvs -d:pserver', so the better commands is

cvs z3 -d:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co -P mozilla/js/src
lingo
UOX3 Novice
Posts: 55
Joined: Thu Jul 07, 2005 12:26 pm
Location: Taipei, Taiwan
Has thanked: 0
Been thanked: 0

Post by lingo »

I find out the mozilla JS library is packaged by pretty much every major linux, bsd distributions.

In debian- libsmjs-dev
In gentoo- spidermonkey
In freebsd - js-1.5.p6
...etc

So you just have to use your favorite package installation mechanism to install it. But there is a problem, the library name is different, the include header is in different places in different distributions. So you have to watch it out.
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Thanks lingo, I'll correct the instructions accordingly.

Note that UOX3 uses the spidermonkey implementation of the mozilla JS library and not the "ordinary" one, but from the examples you give of librarynames for debian/gentoo etc. it looks like you already know. :)
-= Ho Eyo He Hum =-
Inkvisitor
UOX3 Newbie
Posts: 4
Joined: Thu Feb 02, 2006 7:42 pm
Has thanked: 0
Been thanked: 0

Post by Inkvisitor »

Successfull compile on Debian GNU/Linux (Sarge GCC 3.3.5) 2006-02-02:

CVS sources from openuo are not perfectly prepared for a quick compile on GNU, so here is how I did it:

1. cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/openuo co -P projects/uox3/source
2. cvs -z3 -d:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co -P mozilla/js/src
3. cd mozilla/js/src
4. make -ref Makefile.ref
5. cp Linux_All_DBG.OBJ/jsautocfg.h .
6. ar -r js32.a fdlibm/Linux_All_DBG.OBJ/*.o Linux_All_DBG.OBJ/*.o
7. cp js32.a ../../../ ; cd ../../../
8. Edited Makefile.am and changed "uox3_LDADD = @UOX3_LIBS@" to "uox3_LDADD = js32.a -lpthread"
9. Commented first occurance of "#define INADDR_NONE" in socket_interface.h (it's already defined somewhere else and will create a lot of spam/warnings later on at make)
10. Copied configure.in from the old sources (required by autoconf/automake)
11. touch README NEWS AUTHORS
12. aclocal-1.9
13. automake-1.9 --add-missing
14. autoconf
15. ./configure
16. make

And that should be it. There were a few functions in the code that g++ chokes on, but Maarcus helped me fix those and updated to CVS.
Last edited by Inkvisitor on Thu Feb 02, 2006 9:39 pm, edited 1 time in total.
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

For any others that read this thread, to save you some time...

OpenUO also has a /build/ directory on the same level as the /source/ directory, this contains most/all of the needed build files to compile the source under linux. I'm also happy to add/update them as necesarry if someone brings an issue to my attention.
Scott
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

GhostTyper has created a .pdf file documenting what he did to compile & get UOX3 running on Linux.

Thanks GhostTyper :)
-= Ho Eyo He Hum =-
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Hm. I've installed Ubuntu Linux 6.0.6 on my laptop, and have been trying to compile UOX3 for some time now...

I'm a complete Linux noob, but by following GhostTyper's PDF guide (which seems to follow pretty much the same path as Inkvisitor did), I've finally (after installing gcc, make, automake/autoconf, etc. and so forth) gotten the the point where I'm supposed to run aclocal-1.9...

The following error pops up:
NONE:0: /usr/bin/m4: ERROR: EOF in string
autom4te: /usr/bin/m4 failed with exit status: 1
aclocal: autom4te failed with exit status: 1
Help? :P
-= Ho Eyo He Hum =-
jnz
UOX3 Newbie
Posts: 5
Joined: Sun Nov 19, 2006 3:04 pm
Has thanked: 0
Been thanked: 0

Post by jnz »

Step 2: Compiling UOX3

uox3 compile on linux slackware :: UOX3 v0.98-3.7

-
My conf:
Slackware 10.1.0
gcc-4.0.2/configure --prefix=/usr/local --enable-languages=c,c++
-

0. pwd
(result: /home/uox3/)

1. cvs -z3 -d:pserver:anonymous@openuo.cvs.sourceforge.net:/cvsroot/openuo co -P projects/uox3/source

2. cd projects/uox3/source

3. http://downloads.ghost-home.de/uox3.tar.bz2 <- there is uox3/source -> mozilla/ folder , upload it to your projects/uox3/source dir.
after upload, chmod +x mozilla/js/src/Linux_All_DBG.OBJ/*
(NOT WORKING for compilation-> cvs -z3 -d:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co -P mozilla/js/src)

4. mcedit socket_interface.h
// Replace str 38 #define INADDR_NONE with //#define INADDR_NONE in file socket_interface.h

5. touch configure.in

6. mcedit configure.in
// put this code to file configure.in:
AC_INIT(uox3.cpp)
AM_INIT_AUTOMAKE(uox3,0.97)
AC_PROG_CXX
AC_C_CONST
CXXFLAGS="-O2 -I./mozilla/js/src"
AC_ARG_ENABLE(debug, [ --enable-debug compile with debugging support],,enable_debug=no)
if test "$enable_debug" = yes ; then
CXXFLAGS="$CXXFLAGS -g3"
AC_DEFINE(DEBUG, 1, [Define if debugging is enabled.])
fi
dnl To enable debugger support, remove the "dnl" from the line 3 lines down
dnl and recompile the entire application
dnl CXXFLAGS="$CXXFLAGS -g"
AC_OUTPUT(Makefile)
// end of code

7. mcedit uoxlinux.h
// Replace str 4 #include <cstdlib.h> with #include <stdlib.h>

8. mcedit Makefile.am
// Add this cpp file to the list: PartySystem.cpp \

9. mcedit Makefile.in
// Add in all lists what you see there (3), -> PartySystem.cpp (like in list)

10. mcedit PartySystem.cpp
// Replace str 9,10 with: const int BIT_LEADER = 0 , const int BIT_LOOTABLE = 1

12. mcedit autogen.sh
// Replace str 21: gcc -g -c -DXP_UNIX *.c ; ar -r js32.a *.o
// with this:
// make -ref Makefile.ref
// ar -r js32.a Linux_All_DBG.OBJ/*.o Linux_All_DBG.OBJ/*.o

11. sh autogen.sh

12. make

DONE !!!

uox3@www:~/projects/uox3/source$ ls -la uox*
-rwxr-xr-x 1 uox3 users 5312412 2006-11-24 21:30 uox3*
-rw-r--r-- 1 uox3 users 98109 2006-09-20 08:24 uox3.cpp
-rw-r--r-- 1 uox3 users 2547 2006-03-16 09:33 uox3.h
-rw-r--r-- 1 uox3 users 766 2004-07-17 03:03 uox3.ico
-rw-r--r-- 1 uox3 users 150512 2006-11-24 21:27 uox3.o
-rw-r--r-- 1 uox3 users 1638 2006-03-06 02:47 uox3.rc
-rw-r--r-- 1 uox3 users 1070 2006-11-24 21:00 uoxlinux.h
-rw-r--r-- 1 uox3 users 5780 2006-07-01 23:45 uoxstruct.h
uox3@www:~/projects/uox3/source$

after compilation

upload all files from -> all-in-one*.zip archive (download it from uox3.org)

then

$ rm uox3.exe
$ rm js32.dll

then copy linux binary uox3 to folder where was uox3.exe

then need dos2unix some files from zip archive

cd to dir where is uox3 binary now..

download dos2unix soft
$ wget http://primates.ximian.com/~fejj/dos2unix.c
$ gcc dos2unix.c -o dos2unix

then

$ find . -name "*.dfn" > a.sh
$ find . -name "*.uad" >> a.sh
$ find . -name "*.js" >> a.sh
$ find . -name "*.adm" >> a.sh
$ find . -name "*.ENG" >> a.sh
$ find . -name "*.FRE" >> a.sh
$ find . -name "*.UNK" >> a.sh
$ find . -name "*.ZRO" >> a.sh

then

$ mcedit a.sh
press F4 and replace all: ./
with: dos2unix ./

then

$ sh a.sh
$ dos2unix uox.ini

configure uox.ini paths and IP's

Gr33tz t0 Xuri :: on :: irc.freenode.org #uox3

Not working totaly, buggy..
bugs with: js/*.scp files..
Last edited by jnz on Sat Nov 25, 2006 2:18 am, edited 3 times in total.
jnz
UOX3 Newbie
Posts: 5
Joined: Sun Nov 19, 2006 3:04 pm
Has thanked: 0
Been thanked: 0

Post by jnz »

TO START COMPLITLY WORKING UOX3.exe ON LINUX

1. Download and install latest Wine to your linux www.winehq.org

2. Download latest uox3 for windows

3. Extract all files from .zip , and upload they to linux

4. Then configure your putty (telnet client)
Check [x] Terminal -> Implicit CR in every LF

5. cd to folder where is uox3.exe

5. Configure uox.ini paths, IP's, (upload all uo files etc.)

5. run command: wine uox3.exe

Thats all !

-
detected bugs:

no colors in console, and can't send any command to uox3 console like * , Esc.. etc.
punt
VIP
Posts: 244
Joined: Wed Mar 24, 2004 7:46 pm
Has thanked: 0
Been thanked: 9 times

Post by punt »

Hmm, that isn't really having uox3 working on linux, just working under wine under linux.

In theory, uox3 supports linux natively, so running wine isnt the most desired.
Cavalier
UOX3 Newbie
Posts: 18
Joined: Wed Feb 21, 2007 11:19 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by Cavalier »

Compile Platform:
System uname: 2.6.20-gentoo i686 AMD Athlon(tm) 64 Processor 3200+
gcc 4.1.2
glibc 2.5

UOX3 from CVS
Spidermonkey (CVS HEAD currently gives assertion failures on UOX3 startup)

Instructions:

Code: Select all

1. cd ~
2. mkdir -p projects/uox3
3. cd projects/uox3
4. cvs -z3 -d:pserver:anonymous@openuo.cvs.sourceforge.net:/cvsroot/openuo co -d source -P projects/uox3/source
5. cd source
6. cvs -z3 -d:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co -P mozilla/js/src
7. cd mozilla/js/src
8. make -ref Makefile.ref
9. cp Linux_All_DBG.OBJ/jsautocfg.h .
10. ar -r js32.a Linux_All_DBG.OBJ/*.o
11. cp js32.a ~/projects/uox3
12. cd ~/projects/uox3
13. touch README NEWS AUTHORS
14. aclocal-1.9
15. automake-1.9 --add-missing
16. autoconf

17. *Apply fixes to source*

18. ./configure
19. make
 
20. Sort out rest of required files.
21. Run
Fixes needed against CVS HEAD as of this post:
1. socket_interface.h - comment out line 38 (#define INADDR_NONE)
2. uoxlinux.h - change #include <cstdlib> to #include <stdlib>
3. network.h - remove the extra qualifiers on the CPacketStream constructor and deconstructor - required by GCC >=4.1.x
4. Add PartySystem.cpp to build related stuff
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Excellent work Cavalier. Honestly I just don't know the issues with the *nix compiles until someone struggles through getting it compiled and running. :P

I've made the changes you noted, and they will be in my next CVS commit.
Cavalier
UOX3 Newbie
Posts: 18
Joined: Wed Feb 21, 2007 11:19 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by Cavalier »

Hmm, I wasn't expecting that all to get included in CVS :P

I forgot to include the configure.ac, will post updated instructions in a bit.
Last edited by Cavalier on Sat Feb 24, 2007 12:44 am, edited 1 time in total.
Cavalier
UOX3 Newbie
Posts: 18
Joined: Wed Feb 21, 2007 11:19 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by Cavalier »

Ok, new build instructions, should work for any Linux distro (consider the previous instructions incomplete):

PLEASE NOTE: Instruction 6 and 18 should be using "w"get, not "doubleu"get. apache and mod_security blocks that particular phrase.

Code: Select all

1. cd ~
2. mkdir -p projects/uox3
3. cd projects/uox3
4. cvs -z3 -d:pserver:anonymous@openuo.cvs.sourceforge.net:/cvsroot/openuo co 
-d source -P projects/uox3/source
5. cd source
6. mkdir mozilla
7. cd mozilla
8. doubleuget http://ftp.mozilla.org/pub/mozilla.org/js/js-1.60.tar.gz
9. tar xvf js-1.60.tar.gz
10. cd js/src
11. make -ref Makefile.ref
12. cp Linux_All_DBG.OBJ/jsautocfg.h .
13. ar -r js32.a Linux_All_DBG.OBJ/*.o
14. cp js32.a ~/projects/uox3/source
15. cd ~/projects/uox3/source
16. doubleuget http://uox3.cvs.sourceforge.net/*checkout*/uox3/uox3/source/configure.in?revision=1.3 -O configure.in 
17. touch README NEWS AUTHORS
18. aclocal-1.9
19. automake-1.9 --add-missing
20. autoconf
21. ./configure

22. *Apply fixes and your own changes to source*
23. make
 
24. Sort out rest of required files.
25. Run
No fixes required against CVS HEAD as of this post. Although, if you included the configure.in file from the old repository in projects/uox3/source it would save a step.

Perhaps I should just look at fixing up projects/uox3/build instead, but then you VS guys should move your junk out of projects/uox3/source too :P

Knowing how to build spidermonkey and sorting out the rest of the required files are the only real problems with running uox3 on Linux.
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Actually I agree that our VS projects should not be in the /source/ dir, but in the /build/ dir.


I'm just lazy :)

[EDIT]

This computer doesn't happen to have the UOX3 CVS dirs on it, but when I'm next on my Desktop I'll look into adding configure.in to the OpenUO repository.
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

I've added the Configure.in to the /build/ dir of the OpenUO repository.
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Cavalier wrote: Spidermonkey (CVS HEAD currently gives assertion failures on UOX3 startup)
Perhaps we should post it as a bug somehow on the JavaScript bug-list to try and get the issue resolved so we can use the latest CVS version?
-= Ho Eyo He Hum =-
Post Reply