TrippHop Posted May 18, 2010 Share Posted May 18, 2010 For this guide we will be using GCC which is a free C compiler for Linux. Also this guide is kind of a work in progress, as I am a new user of linux, GCC, and makefiles. The first thing you need to compile on linux is access to a linux platform. Access to a linux platform could be on a server or your home computer. For this guide I used the Ubuntu linux distro ( http://www.ubuntu.com ). A very easy way to install ubuntu on your computer is to use WUBI ( http://wubi-installer.org/ ). You can also use VirtualBox or VMWare Player to run linux on a virtual machine on your windows platform. I don't personally like this method because it runs really slow, for me at least. Also make sure you have the latest version of GCC with your linux distro. With Debian/Ubuntu distros you can do "sudo apt-get install gcc" in the terminal. Next step is to make sure you have a copy of the Jedi Academy SDK provided by Raven Software. Here is a link to download: http://jediknight3.filefront.com/file/Jedi_Academy_SDK_MP;20909 Off the bat, the source files will not compile with GCC without errors, so we are going to fix them. GCC will complain about instances of redefinition, which there are a few in the source files. Step 1) Find all instances of the function powf and rename it to Q_powf. in q_shared.h: change float powf ( float x, int y ); to this: float Q_powf ( float x, int y ); and in q_math.c, change this: float powf ( float x, int y ) { float r = x; for ( y--; y>0; y-- ) r = r * r; return r; } to this: float Q_powf ( float x, int y ) { float r = x; for ( y--; y>0; y-- ) r = r * r; return r; } Also if your mod is client side you will want to pay attention to cg_view.c since powf is used twice: at line 444: ratio = powf(dampfactor, dtime); and line 531: ratio = powf(dampfactor, dtime); Step 2) Fixing bg_vehicles.h In bg_vehicles.h there is a typedef redefinition. Go to line 477 where you see: // This is the implementation of the vehicle interface and any of the other variables needed. This // is what actually represents a vehicle. -AReis. typedef struct Vehicle_s { // The entity who pilots/drives this vehicle. // NOTE: This is redundant (since m_pParentEntity->owner _should_ be the pilot). This makes things clearer though. bgEntity_t *m_pPilot; change it to // This is the implementation of the vehicle interface and any of the other variables needed. This // is what actually represents a vehicle. -AReis. #ifdef __GCC__ struct Vehicle_s #else typedef struct Vehicle_s #endif { // The entity who pilots/drives this vehicle. // NOTE: This is redundant (since m_pParentEntity->owner _should_ be the pilot). This makes things clearer though. bgEntity_t *m_pPilot; and after this struct where: //the guy who was previously the pilot bgEntity_t * m_pOldPilot; } Vehicle_t; change it to: //the guy who was previously the pilot bgEntity_t * m_pOldPilot; #ifdef __GCC__ }; #else } Vehicle_t; #endif Step 3) Fixing bg_public.h The same type of redefinition occurs in bg_public.h Go to line 423 where you see: typedef struct bgEntity_s { entityState_t s; change it to: #ifdef __GCC__ struct bgEntity_s #else typedef struct bgEntity_s #endif { entityState_t s; and after the struct where you see: //Data type(s) must directly correspond to the head of the gentity and centity structures } bgEntity_t; change it to: //Data type(s) must directly correspond to the head of the gentity and centity structures #ifdef __GCC__ }; #else } bgEntity_t; #endif Step 4) Fixing g_public.h Yep, another redefinition here. Go to line 675 where you see: typedef struct Vehicle_s Vehicle_t; change it to: #ifndef __GCC__ typedef struct Vehicle_s Vehicle_t; #endif Step 5) Fixing bg_pmove.c Go to line 712 where you see: // Following couple things don't belong in the DLL namespace! #ifdef QAGAME typedef struct gentity_s gentity_t; gentity_t *G_PlayEffectID(const int fxID, vec3_t org, vec3_t ang); #endif change this to: // Following couple things don't belong in the DLL namespace! #ifdef QAGAME #ifndef __GCC__ typedef struct gentity_s gentity_t; #endif gentity_t *G_PlayEffectID(const int fxID, vec3_t org, vec3_t ang); #endif Step 6) Fixing g_ICARUScb.c Go to line 30 where: #ifndef _XBOX #ifndef __linux__ enum { TK_EOF = -1, TK_UNDEFINED, TK_COMMENT, change it to: #ifndef _XBOX //#ifndef __linux__ #if defined(__linux__) && defined(__GCC__) || !defined(__linux__) enum { TK_EOF = -1, TK_UNDEFINED, TK_COMMENT, Step 7) Fixing g_main.c Go to line 500 where: #include "../namespace_begin.h" #ifdef __linux__ extern "C" { #endif change it to: #include "../namespace_begin.h" //#ifdef __linux__ #if defined(__linux__) && !defined(__GCC__) extern "C" { #endif and after that function, change: } #ifdef __linux__ } #endif to: } //#ifdef __linux__ #if defined(__linux__) && !defined(__GCC__) } #endif Okay that ends the editing of the source files. Now it is time to create the Makefile. Makefiles provide a convenient means to building source files into executables or shared libraries. Go to the codemp/game directory and inside it make a file named "Makefile". then just copy this stuff into the makefile and save it: # # Linux Makefile for GCC for Jedi Academy SDK # # === Variables === # Compiler - GCC CC = gcc # Compiler Flags # -D<name> ( Used to make a define like #define mydefine ) # -w ( disable warnings ) # -I<include path> used to include headers # -fPIC ( this flag is necessary to build shared libraries ) CFLAGS = -I../qcommon -I../server -I../icarus -I../ghoul2 -fPIC -DFINAL_BUILD -DMISSION_PACK -DQAGAME -D_JK2 -D__linux__ -D__GCC__ -w # Target file TARGET = jampgamei386.so # Object Files OFILES = ai_main.o ai_util.o ai_wpnav.o AnimalNPC.o \ bg_g2_utils.o bg_lib.o bg_misc.o bg_panimate.o \ bg_pmove.o bg_saber.o bg_saberLoad.o bg_saga.o \ bg_slidemove.o bg_vehicleLoad.o bg_weapons.o \ FighterNPC.o g_active.o g_arenas.o g_bot.o \ g_client.o g_cmds.o g_combat.o g_exphysics.o \ g_ICARUScb.o g_items.o g_log.o g_main.o g_mem.o \ g_misc.o g_missile.o g_mover.o g_nav.o g_navnew.o \ g_object.o g_saga.o g_session.o g_spawn.o g_strap.o \ g_svcmds.o g_target.o g_team.o g_timer.o g_trigger.o \ g_turret.o g_turret_G2.o g_utils.o g_vehicles.o \ g_vehicleTurret.o g_weapon.o NPC.o NPC_AI_Atst.o \ NPC_AI_Default.o NPC_AI_Droid.o NPC_AI_GalakMech.o \ NPC_AI_Grenadier.o NPC_AI_Howler.o NPC_AI_ImperialProbe.o \ NPC_AI_Interrogator.o NPC_AI_Jedi.o NPC_AI_Mark1.o \ NPC_AI_Mark2.o NPC_AI_MineMonster.o NPC_AI_Rancor.o \ NPC_AI_Remote.o NPC_AI_Seeker.o NPC_AI_Sentry.o \ NPC_AI_Sniper.o NPC_AI_Stormtrooper.o NPC_AI_Utils.o \ NPC_AI_Wampa.o NPC_behavior.o NPC_combat.o NPC_goal.o \ NPC_misc.o NPC_move.o NPC_reactions.o NPC_senses.o \ NPC_sounds.o NPC_spawn.o NPC_stats.o NPC_utils.o \ q_math.o q_shared.o SpeederNPC.o tri_coll_test.o \ WalkerNPC.o w_force.o w_saber.o # === Arguments for the Makefile === # typing just "make" invokes the first target ( which in this case is $(TARGET) ) $(TARGET): $(OFILES) $(CC) -shared -o $(TARGET) $(OFILES) -lm .c.o: $(CC) $(CFLAGS) -c $*.c -o $*.o # "make clean" clean: rm -f $(OFILES) rm -f $(TARGET) now with a terminal go to codemp/game and type "make". This will build the shared libray jampgamei386.so which will be in codemp/game. You can use "make clean", which will remove all the object files and the libary file in codemp/game. This guide will probably change since im new to all this *nix stuff. Also, fyi. I did not test this shared library on a server yet. So I am not sure if there are any runtime errors. Link to comment Share on other sites More sharing options...
elraro Posted July 29, 2010 Share Posted July 29, 2010 Loading dll file jampgame. Sys_LoadDll(/home/jk31/base/jampgamei386.so)... Sys_LoadDll(/home/jk31/base/jampgamei386.so) failed: "/home/jk31/base/jampgamei386.so: undefined symbol: trap_PointContents" Sys_LoadDll(./linuxjampded/base/jampgamei386.so) failed: "./linuxjampded/base/jampgamei386.so: cannot open shared object file: Not a directory" Resolving masterjk3.ravensoft.com masterjk3.ravensoft.com resolved to 63.146.124.53:29060 Sending heartbeat to masterjk3.ravensoft.com Sending heartbeat to masterjk3.ravensoft.com Sys_Error: Sys_LoadDll(jampgame) failed dlopen() completely! help Link to comment Share on other sites More sharing options...
-=*Raz0r*=- Posted July 31, 2010 Share Posted July 31, 2010 Confirmed, the same error occurs for me. That's absurd. EDIT: Scratch that, just add g_syscalls.o to the list and it should work (After you fix the extern "C" issue in that file the same way you did with vmMain in g_main.c) Thanks Subaru Though eh, I'm getting a segfault as soon as the map loads - this may just be my mod though, I haven't tested on base. EDIT: Base works...fine...except when I connect with my windows client I get dropped to the console with "Shutting down OpenGL subsystem...ERROR: no shader files found" Wat. EDIT: All works fine, just had to actually START the server with sv_pure 0 (As opposed to changing + restarting...odd yah) Many thanks to TrippHop, Xycaleth, Subaru Link to comment Share on other sites More sharing options...
TrippHop Posted August 1, 2010 Author Share Posted August 1, 2010 Hey, sorry guys I never got around testing this to make sure it works. I will do it soon when I get my linux distro working again. Also, FYI, the __linux__ macro is for Intel C++ Compiler Linux version which is kind of confusing in cases like these: #include "../namespace_begin.h" //#ifdef __linux__ #if defined(__linux__) && !defined(__GCC__) extern "C" { #endif So if you were going to compile with Intel C++ Compiler you could probably be safe with defining __linux__ and without making any source changes. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.