Compiling a mod under GNU/Linux


(jaybird) #61

huh? What’s doing that?


(kamikazee) #62

W:ET extracts the client libraries from mp_bin.pk3 when it sees inconsistencies. Make sure the correct version is package in mp_bin.pk3 (eventually backup your old version by renaming it to mp_bin.pk3.01) and delete all .so files.
Packaging can be done trough a script, using the zip shell program.


(nUllSkillZ) #63

I’ve found the mistake:
After starting the compilation again simply with “scons” the mingw32 compiler is still used and the compiled files are “.dll”'s.
Not sure why.
I’ve tried compilation with a “fresh” installation and gcc is used (the files are “.so”'s)

The Mingw32 has been started as described here:
Compiling for Windows under Linux - cross-scons.sh


scons -c CC=i586-mingw32msvc-gcc CXX=i586-mingw32msvc-g++
scons CC=i586-mingw32msvc-gcc CXX=i586-mingw32msvc-g++

I guess that some configuration files have been written which are then used.


(kamikazee) #64

SCons saves the last supplied building parameters in site.conf. Now, when cross-scons.sh is executed, SCons saves those values.
To revert to the default Linux compiles, delete site.conf or execute SCons with these parameters:

CC=gcc CXX=g++

(nUllSkillZ) #65

Yep just have had a look.
I’ve deleted “site.conf” and everything works.
Thanks for the help.


(=>ETK<=Elite) #66

Lol, ran into this myslef, thought I broke linux compilations somehow for awhile.

You don’t need to delete that file. Would be a pain to do all the time. All you need to do is just set it like you did to get the windows builds with the args so they can be reset.

Windows:

scons -c CC=i586-mingw32msvc-gcc CXX=i586-mingw32msvc-g++
scons CC=i586-mingw32msvc-gcc CXX=i586-mingw32msvc-g+ BUILD=release

Linux:

scons -c CC=gcc CXX=g++
scons CC=gcc CXX=g++ BUILD=release

I use a script to compile both builds at once. I blanked out my paths, but just replace with wherever your files are. It simply compiles everything for both windows and linux, and moves it into a folder on my desktop for later when I turn it into a pak. I also have a script to make everything in my folder a pak, but just in case I am adding extra models and such I left that out from this script.

SOURCE_DIR="/usr/local/games/************/src"
FINAL_DIR=$SOURCE_DIR/final
PAK_DIR="/home/*****/Desktop/******"

prepare()
{
	echo "Preparing to compile..."
	cd $SOURCE_DIR
	rm -rf $FINAL_DIR
	mkdir $FINAL_DIR
}

windows_compile()
{
	cd $SOURCE_DIR

	echo "Removing old windows builds..."
	scons -c CC=i586-mingw32msvc-gcc CXX=i586-mingw32msvc-g++

	echo "Compiling windows builds..."
	scons CC=i586-mingw32msvc-gcc CXX=i586-mingw32msvc-g+ BUILD=release

	echo "Finishing windows builds..."
	mv cgame.mp.i386.so $FINAL_DIR/cgame.mp.i386.dll
	mv ui.mp.i386.so $FINAL_DIR/ui.mp.i386.dll
	mv qagame.mp.i386.so $FINAL_DIR/qagame.mp.i386.dll

	cd $FINAL_DIR
	strip *.dll
}

linux_compile()
{
	cd $SOURCE_DIR

	echo "Removing old linux builds..."
	scons -c CC=gcc CXX=g++

	echo "Compiling linux builds..."
	scons CC=gcc CXX=g++ BUILD=release

	echo "Finishing linux builds..."
	mv cgame.mp.i386.so $FINAL_DIR
	mv ui.mp.i386.so $FINAL_DIR
	mv qagame.mp.i386.so $FINAL_DIR

	cd $FINAL_DIR
	strip *.so
}

finish()
{
	cd $FINAL_DIR

	echo "Finishing builds..."
	mv * $PAK_DIR
}

prepare
windows_compile
linux_compile
finish

Here’s the script to place everthing in my pak…

PAK_DIR="/home/*****/Desktop/******"
PAK_FILE="******-1.0.0.pk3"
SERVER_DIR="/usr/local/games/enemy-territory/27960/******"
CLIENT_DIR="/home/*****/.etwolf/******"

make_pak()
{
	echo "Creating pak..."
	cd $PAK_DIR
	zip -r ******-1.0.0.zip *
	mv ******-1.0.0.zip $PAK_FILE

	echo "Moving pak to server..."
	cp $PAK_FILE $SERVER_DIR
	cp qagame.mp.i386.so $SERVER_DIR

	echo "Moving pak to client..."
	cp $PAK_FILE $CLIENT_DIR

	echo "Removing old files..."
	rm *
}

make_pak

If you know you aren’t going to be needing any extra models, sounds, etc, this could just be placed in the script for compiling, and then you have everything done in one command. Just move everything from $FINAL_DIR straight to a zipfile in the final() block.

So, all in all, after I run the compile script, I have both windows and linux builds done, then I just run my pak script and it places the pak/necessary files in the proper directory so I can test it on my test server,


(nUllSkillZ) #67

Thnx for the info and the scripts.
The uixxx.so file is still overwritten by the original one.
The reason might be that I haven’t changed code in the ui part.


(jaybird) #68

Using a script to seperate the output bins is kinda beating around the bush a little bit. Here’s the fix for the scons script.

In SConstruct, find the targets section, towards the bottom, and change it to look like this (notice the if and else block in each module)

if ( TARGET_GAME == '1' ):
	Export( 'GLOBALS ' + GLOBALS )
	BuildDir( g_build + '/game', '.', duplicate = 0 )
	game = SConscript( g_build + '/game/SConscript.game' )
	if ( win32_build == 1 ):
		toplevel_targets.append( InstallAs( '#qagame_mp_x86.dll', game ) )
	else:
		toplevel_targets.append( InstallAs( '#qagame.mp.%s.so' % dll_cpu, game ) )

if ( TARGET_CGAME == '1' ):
	Export( 'GLOBALS ' + GLOBALS )
	BuildDir( g_build + '/cgame', '.', duplicate = 0 )
	cgame = SConscript( g_build + '/cgame/SConscript.cgame' )
	if ( win32_build == 1 ):
		toplevel_targets.append( InstallAs( '#cgame_mp_x86.dll', cgame ) )
	else:
		toplevel_targets.append( InstallAs( '#cgame.mp.%s.so' % dll_cpu, cgame ) )

if ( TARGET_UI == '1' ):
	Export( 'GLOBALS ' + GLOBALS )
	BuildDir( g_build + '/ui', '.', duplicate = 0 )
	ui = SConscript( g_build + '/ui/SConscript.ui' )
	if ( win32_build == 1 ):
		toplevel_targets.append( InstallAs( '#ui_mp_x86.dll', ui ) )
	else:
		toplevel_targets.append( InstallAs( '#ui.mp.%s.so' % dll_cpu, ui ) )


(=>ETK<=Elite) #69

The way my script works is this (and it shouldn’t be overwriting anything, because the builds all get moved into a separate directory, and are renamed accordingly before any other builds could overwrite it, so I don’t exactly know what’s going on there.)

  • Compiles windows builds
  • moves windows builds to separate directory, renames them properly to dll’s
  • cleans up all object files (just to make sure linux gets a clean build)
  • compiles linux builds
  • moves linux builds to separate directory

In the end after running the script there should be 6 files in the $FINAL_DIR. 3 dll’s and 3 so’s.

Never tried Jaybird’s method yet. I just use mine becuase I only have to type 1 command to do both builds, eitherhow I don’t have to worry about renaming them each time, the script does it anyhow. In the end both ways work, and they end up as dll’s eitherway.

===================================================
One more note. Didn’t notice this until just now, but if you use that pak script, it will place the qagame files inside as well.

EDIT:
Here is a fixed version:

PAK_DIR="/home/*****/Desktop/******"
PAK_FILE="******-1.0.0.pk3"
SERVER_DIR="/usr/local/games/enemy-territory/27960/******"
CLIENT_DIR="/home/*****/.etwolf/******"

make_pak()
{
	echo "Creating pak..."
	cd $PAK_DIR
	mv qagame.mp.i386.so $SERVER_DIR
	rm qagame.mp.i386.dll
	zip -r ******-1.0.0.zip *
	mv ******-1.0.0.zip $PAK_FILE

	echo "Moving pak to server..."
	cp $PAK_FILE $SERVER_DIR

	echo "Moving pak to client..."
	cp $PAK_FILE $CLIENT_DIR

	echo "Removing old files..."
	rm *
}

make_pak

I just delete the old files after I compile it and get it all ready to test on the server. If you prefer to keep these files in place just swap the rm command with cp.


(jaybird) #70

The difference between “methods” is that one is a workaround while one is a fix.


(=>ETK<=Elite) #71

Ok, I’m going to listen to Jaybird on this one a bit and move it a step further. Please don’t use the scripts I posted…something is not right with them. I will post up a better script to use in a bit when I complete it with options that can be set instead of having 10 copies of sconstruct and site.conf lying around.

I actually took a deeper look into the sconstruct file and found some interesting stuff that somehow I managed to pass by. Very important to look carefully in there…lesson learned.

EDIT:
Ok, got it created and is much, much better. I posted it here:
http://www.splashdamage.com/index.php?name=pnPHPbb2&file=viewtopic&t=15599


(Ranana_Assery) #72

Mm… So, how does one go about compiling binary scripts and decls, precisely? exportScript when my mods loaded seems to just crap itself with errors when trying to copy the stuff in the /base/src dirs, although the stuff in the moddir itself seems to copy fine.
And whats the equivalent to exportScript with decls, or are they automatically included with it?
No problems compiling windows and linux code itself, beyond going wtf over scons instead of make. :stuck_out_tongue:


(-IronMonkey-) #73

!revive topic

hello :slight_smile:
i have my own MOD compiled and running under Windows,
now i was trying to compile it for Linux, but i have NO knowledge about this OS

my MOD is built over ETpub 0.8.1 so following the readme files and this SD tutorial,
i was able to have my .so files released

now there is my problem, when i start the server i get this:


Sys_LoadDll(/usr/local/games/et/vietnam/qagame.mp.i386.so)...
Sys_LoadDll(/usr/local/games/et/vietnam/qagame.mp.i386.so) failed:
"/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found
(required by /usr/local/games/et/vietnam/qagame.mp.i386.so)"
Sys_LoadDll(qagame) failed dlopen() completely!

since i know nothing about Linux,
i asked to the server host if this problem was related to some needed upgrade on server
well he replied to me:

This indicates an error relating to how you compiled it.
You would need to compile it without the dependency on glibc.

somebody can tell me how can i do that?
I compile the MOD using Ubuntu 9.10, scons, and the SConstruct file included into ETpub 0.8.1

thanks in advance :smiley:


(Cambodunum) #74

you have to use an old linux … for example debian 4
… there are old glibc’s included … thats all i know atm :slight_smile:


(-IronMonkey-) #75

thank you
this solved my problem :smiley:


(Cambodunum) #76

v44 :slight_smile:

btw … how did you install debian? … im trying to get it running since 2 month as a virtual machine … it allways stops installing at the additional downloads … (got stuck and thats it) :frowning:

… thinking about to rape again my very very very old laptop for it xD


(-IronMonkey-) #77

i downloaded this .iso file
(internet installation)
http://cdimage.debian.org/cdimage/archive/4.0_r8/i386/iso-cd/debian-40r8-etchnhalf-i386-netinst.iso
but here you have different .iso images, you can try to use different files
http://cdimage.debian.org/cdimage/archive/4.0_r8/i386/iso-cd/

i installed it into an empty external HD …
at the end of the installation it creates a boot file that allow you to select your OS when you start your PC

the only problem i had was after mounting my primary NTFS hard disk
( where i have installed windows and also stored my source code ),
after restarting my PC the boot file crash so i need to reinstall Debian…
and this happens every time i mounted the hard disk ( lol i reinstalled Debian many times :stuck_out_tongue: )

i solved this copying my source code into an USB key…
so when i run Debian i don’t need to mount my NTFS hard disk to load my needed source files

anyway it’s the first time i run and use Linux so probably there are better ways and solutions


(Cambodunum) #78

… damn neither these netinstalls nor a complete dvd is working with any virtual machine … seems like my sin7 doesnt like em … gonna try to install it on a additional hdd or maybe on a usb-stick


(Paul) #79

Working on the rest of my windows tutorial I should have made a long time ago: compiling .so in virutal box @ windows… A lot easier =D


(Cambodunum) #80

… just gimme a working image of a virtual debian etch xD and im happy :smiley: