r1ch.net forums
* Home Help Search Login Register
r1ch.net  |  r1ch.net stuff  |  R1Q2  |  Topic: compile r1ch, original q2 src, or gamex86.dll using Dev-C++
Pages: [1]
Print
Author Topic: compile r1ch, original q2 src, or gamex86.dll using Dev-C++  (Read 10435 times)
ravenwolf
Member

Posts: 31



« on: October 18, 2010, 12:19:44 am »

Sup ppl, i had problems when i tried to compile r1ch source, or original 3.21 q2 source (also older versions), or gamex86... in few words, i wasnt able to compile a single thing from q2... I had too many errors to try to post it right now, so im lookin for a generlal guindance on how to do it on Dev-C++, if anyone is usin it, or any other compiler suggestion?...

After some general procedures to compile it, if i still have problems, ill start posting the particular issues... For now just dont want to flood with (so many) errors messages...

ty!
Logged
ravenwolf
Member

Posts: 31



« Reply #1 on: October 18, 2010, 02:37:42 am »

So, finaly, ill go little more specific... Im working now with the 3.21 source version. Ive got Dev-C++ v 4.9.9.2. So, heres what i do:

Open Devc++, then file>new>project   then i choose "dll", and "c project" (the other option is c++ project). Finally i choose the project name and save it like a .dev file... then hit OK.

After that, automatly two files are created "dllmain.c" and "dll.h", and heres whats inside:

Code: ("dllmain.c")
/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

DLLIMPORT void HelloWorld ()
{
    MessageBox (0, "Hello World from DLL!\n", "Hi", MB_ICONINFORMATION);
}


BOOL APIENTRY DllMain (HINSTANCE hInst     /* Library instance handle. */ ,
                       DWORD reason        /* Reason this function is being called. */ ,
                       LPVOID reserved     /* Not used. */ )
{
    switch (reason)
    {
      case DLL_PROCESS_ATTACH:
        break;

      case DLL_PROCESS_DETACH:
        break;

      case DLL_THREAD_ATTACH:
        break;

      case DLL_THREAD_DETACH:
        break;
    }

    /* Returns TRUE on success, FALSE on failure */
    return TRUE;
}




Code: ("dll.h")
#ifndef _DLL_H_
#define _DLL_H_

#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */


DLLIMPORT void HelloWorld (void);


#endif /* _DLL_H_ */


sincerely, i dunno what r this files for... then... i delete em... he.

So, now, after delleting this two files, what i do is to add all the files on the "game" folder (project>add to project), except for "game.dsp".

then i go to execute>compile and i get this error:

Quote from: errors
419    C:\quake\src\prueba\quake2-3.21\game\q_shared.c        [Warning]    `naked' attribute directive ignored
          C:\quake\src\prueba\quake2-3.21\game\q_shared.c                              In function `BoxOnPlaneSide':
423    C:\quake\src\prueba\quake2-3.21\game\q_shared.c                              syntax error before '{' token
          C:\quake\src\prueba\Makefile.win                                     [Build Error]    [quake2-3.21/game/q_shared.o] Error 1

Heres the code:

Quote from: q_shared.c

__declspec( naked ) int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *p)
{    line 419
   static int bops_initialized;
   static int Ljmptab[8];

   __asm {        line 423

      push ebx
         
      cmp bops_initialized, 1
      je  initialized
      mov bops_initialized, 1


well... any clue? thnx!
Logged
ravenwolf
Member

Posts: 31



« Reply #2 on: October 18, 2010, 02:40:27 am »

Something more: ive got a bunch of .o files generated on the "game" folder...

Also workin on win7...
Logged
wision
Member

Posts: 237



« Reply #3 on: October 19, 2010, 01:32:08 am »

http://www.r1ch.net/forum/index.php?topic=1623.0
if you encounter some more errors, they've been most likely discussed on the forum already.. just search for the answer Smiley
Logged
ravenwolf
Member

Posts: 31



« Reply #4 on: October 20, 2010, 03:59:25 pm »

Ty!, ill check it out... smiley

And for the search... im having problems on seein the buttons of this forum... see more about it on this thread... so every time i wanat to do a search i must logoff.. do it, and login again... its a little... annoying... sad

Hehe, cya, thanks again! wink
Logged
ravenwolf
Member

Posts: 31



« Reply #5 on: October 20, 2010, 07:16:33 pm »

well, still errors... heres what i did, now im using visual c++ 2010...

Now im trying to build only the gamex86.dll from r1ch`s b7431

copied to "microsoft visual studio 10.0/VC/include":

zlib.h

this also included in project:
unzip.c
unzip.h
ioapi.c
ioapi.h

copied to VC/lib:

dsound.lib
user32.lib
kernel32.lib
advapi32.lib
gdi32.lib
comdlg32.lib
shell32.lib

But i didnt added them to linker, dont know even what thats mean (really newbie codder...)

i tried building on debug and release, both givin me same errors:

Quote
1>Link:
1>     Creating library .\./build/binaries/debug\gamex86.lib and object .\./build/binaries/debug\gamex86.exp
1>unzip.obj : error LNK2019: unresolved external symbol _get_crc_table referenced in function _unzOpenCurrentFile3
1>unzip.obj : error LNK2019: unresolved external symbol _inflateInit2_ referenced in function _unzOpenCurrentFile3
1>unzip.obj : error LNK2019: unresolved external symbol _inflate referenced in function _unzReadCurrentFile
1>unzip.obj : error LNK2019: unresolved external symbol _crc32 referenced in function _unzReadCurrentFile
1>unzip.obj : error LNK2019: unresolved external symbol _inflateEnd referenced in function _unzCloseCurrentFile
1>q_shared.obj : error LNK2019: unresolved external symbol _Sys_DebugBreak referenced in function __Q_assert
1>./build/binaries/debug/gamex86.dll : fatal error LNK1120: 6 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:07.85
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========


On a post ive seen this (ive cheked until page 20, half of them, will check the last 20 maybe tomorrow, right now just got too tired, he, wanna sleep, coffe seems to make effect anymore  smiley):

Quote from: R1CH
Make sure platform SDK is installed.

Not sure what thats means, but i had an SDK file created when i installed vc++2010 ... (theres where i found user32, dsound and the other libs...)


Anyway, i got gamex86.dll compiled without problems from the 3.21 code ... Ran a server on win7 without problems, but i had an old notebook and i tried to run a dedicated (using r1chs dedicated) with my new test mode (just double damage weapons and x5 quad), and i get an error... The older notebook its a pIII @800mhz, win xp, and the error windows says:

Quote
Der Prozedureinsprungpunkt "DecodePointer" wurde in der DLL "KERNEL32.dll" nicht gefunden.

Not sure what it means, since it is in German, and i dont have much knowleadge on technical german, but it says something like:

"the initial proces, or start point called DecodePointer, cant be found on KERNELL32.dll ... After that the dedicatesd server loads just baseq2 gamex (no extra damage, i can connect to server and play, but the modifications are not there...)

So, any clue? main issue for me its to get gamx86.dll from r1chs compiled... the server thing just is under priority, for me, for now... he, so, thanx for helpin me, im just learning, i did some basic C programes, with some structures and nice things, but never got into real programing... so this is brand new thing for me...

Again, thnx!
Logged
QwazyWabbit
Member

Posts: 402


« Reply #6 on: October 23, 2010, 02:58:31 am »

Regarding your last post.

The German text reads something like "the DecodePointer function was not found in the kernel32.dll". Make sure you are running the latest Windows XP service packs and updates on the old laptop.

Don't copy those files. You will create problems on the next Windows Update or whenever you update your VC installation.
Keep those files in their proper locations.

VC2010 is different from VC2008 and 2005. They moved a lot of dialogs in the IDE from the tools menu into the project menus.

To build the gamex86.dll you don't need zlib or the other third-party libraries, so just ignore them for now. Select game as the startup project, to make it your default for now. Then click Build, Configuration Manager and click the check boxes in the Build column so only the game dll is selected. Click OK out of the dialog and you should get a clean build of the game DLL.

Depending on your setup and whether you are debugging the game inside the IDE or not (lots of work to make that happen) you might have to move the game DLL and the PDB to the quake2 mod folder for your mod.

Let me know what you get when you compile the game DLL only in that project, I can try to help you from there.

« Last Edit: October 23, 2010, 03:04:09 am by QwazyWabbit » Logged
QwazyWabbit
Member

Posts: 402


« Reply #7 on: October 23, 2010, 03:06:05 am »

Something more: ive got a bunch of .o files generated on the "game" folder...

Also workin on win7...

The .o files are object files, compiled code made from the .c files. Doing a clean on your project will delete them and any programs or DLLs built from them.
Logged
ravenwolf
Member

Posts: 31



« Reply #8 on: October 23, 2010, 01:15:47 pm »

Well, reinstaled VC2010 and deleted the files...

After that, ive done exactly what you told me, and i got this error:

Quote
2>c:\quake\src\insane\r1q2-b7904-src\game\q_shared.h(36): fatal error C1083: Cannot open include file: 'zlib.h': No such file or directory
2>  g_ai.c
2>c:\quake\src\insane\r1q2-b7904-src\game\q_shared.h(36): fatal error C1083: Cannot open include file: 'zlib.h': No such file or directory
2>  Generating Code...
2>
2>Build FAILED.
2>
2>Time Elapsed 00:00:06.78
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 2 skipped ==========

any clue?

im working on r1chs b7904 src now...
Logged
QwazyWabbit
Member

Posts: 402


« Reply #9 on: October 24, 2010, 03:28:46 pm »

OK, good that you're on b7904.

Now you need to download and install the zlib package. This will install the sources and binaries you need. You should also create a solution for the zlib and build debug and release versions as a separate project.

Add the path to the zlib code to the Include Directories of the gamex86 project in your r1q2 solution. This is actually the cleanest method because if you reinstall the zlib package for any updates, you don't have to mess with copying the headers. The tedious part of this is adding that path to every project individually for every project that uses zlib but once it's done, you won't have to worry about it so this is preferable in the long run. It also keeps the VS2010 include directory pure.

Use the project properties dialog to edit the VC++ Directories. I keep my zlib in the Projects folder under VS2010.

The game DLL doesn't link to the zlib.lib so you don't actually need it to compile just the DLL. More is needed to get the engine compiled but lets just concentrate on this.
« Last Edit: October 24, 2010, 04:09:42 pm by QwazyWabbit » Logged
ravenwolf
Member

Posts: 31



« Reply #10 on: October 24, 2010, 10:07:21 pm »

Well.. heres what i did:

i got the files from this page, i downloaded the setup that says "complete package, except sources"... then i just runned the setup and got something installed.

After that i opened r1chs quake2 workspace, then on project->properties->common properties->debug source files... i added this file (that was the only place i found something to add directories... the other tabs or menus had nothing... or their were hidden):

program files (x86)\GnuWin32\include

So, after choosing game as startup project adn selecting only to build game, i got this output:

Quote
2>c:\quake\src\insane\r1q2-b7904-src\game\q_shared.h(36): fatal error C1083: Cannot open include file: 'zlib.h': No such file or directory
2>  Generating Code...
2>
2>Build FAILED.
2>
2>Time Elapsed 00:00:07.47
========== Rebuild All: 0 succeeded, 1 failed, 2 skipped ==========

So, after that i tried something else: right-click on "game" (on the left menu, i think its the projects explorer window) then properties->configuration properties->VC++ directories and there i added the GnuWin32\include directory... i got this:

Quote
2>c:\program files (x86)\gnuwin32\include\zconf.h(289): fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
2>  Generating Code...
2>
2>Build FAILED.
2>
2>Time Elapsed 00:00:05.17
========== Rebuild All: 0 succeeded, 1 failed, 2 skipped ==========

now whats missing is unistd.h ...i think i did some progres... now i use the search tool to fin that in my hard disk... Found nothing...

Ok, i think i did some progress, but now im stuck again...

something more, after intalling the zlib package, i got a zlib1.dll installed on GnuWin23\bin ...

Thanx dude, im making progress with your help... hope i get compiling game soon... thats what im most interested since i want to make a mod...

One more thing, not sure wwhat you mean by:

Quote
Now you need to download and install the zlib package. This will install the sources and binaries you need. You should also create a solution for the zlib and build debug and release versions as a separate project.

After installing the package, i didnt get the source files, but i had an zlib123.rar (or something like that), with the sources... i got the zlib1.dll, do i still need to create a solution and build it?

Thanx again! ill be trying to compile it...
Logged
QwazyWabbit
Member

Posts: 402


« Reply #11 on: October 24, 2010, 11:36:26 pm »

Yes, you need the sources.
Get zlib from here: http://www.zlib.net/

It looks like you are on Win7.
Unpack the zlib125 into Documents\Visual Studio 2010\Projects\zlib
Use the files and README to make a new solution for vc10, I can't remember the exact steps, I know there's an old folder in that tree with a VC6 project in it, I can't remember if I used that and converted or whether I started a new project in VC10. You'll have to figure that out. If you are ONLY interested in building the gamex86.dll you don't need to actually rebuild the zlib code, you only need the headers. Long-term, if you want to build r1q2 for some reason, you will need to master multiproject installs like these. It's a PITA.

Once you have zlib sources and binaries you can point your gamex86 project at the sources so it can use those headers. You won't need the zlib.lib or the dll placed yet, the gamex86.dll doesn't link to them but the switching of the includes in q_shared.h is flawed and the zlib.h file and the zconf.h file must exist on the include path for the r1q2 VC10 solution and associated projects.
« Last Edit: October 24, 2010, 11:39:10 pm by QwazyWabbit » Logged
ravenwolf
Member

Posts: 31



« Reply #12 on: October 25, 2010, 09:12:03 am »

So, heres what i did, i got the zlib125.rar, uncompressed it on the directory u told me, then added that path to the include on the game project (just want to compile the gamex86.dll), and heres the output:

Quote
2>  g_chase.c
2>g_chase.c(147): warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
2>  g_ai.c
2>g_ai.c(653): warning C4305: '=' : truncation from 'double' to 'float'
2>g_ai.c(665): warning C4305: '=' : truncation from 'double' to 'float'
2>  Generating Code...
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(989,5): warning MSB8012: TargetPath(C:\quake\src\insane\r1q2-b7904-src\game\.\./build/binaries/debug\game.dll) does not match the Linker's OutputFile property value (C:\quake\src\insane\r1q2-b7904-src\game\build\binaries\debug\gamex86.dll). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(991,5): warning MSB8012: TargetName(game) does not match the Linker's OutputFile property value (gamex86). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
2>Link:
2>     Creating library .\./build/binaries/debug\gamex86.lib and object .\./build/binaries/debug\gamex86.exp
2>  game.vcxproj -> C:\quake\src\insane\r1q2-b7904-src\game\.\./build/binaries/debug\game.dll
2>FinalizeBuildStatus:
2>  Deleting file ".\./build/temp/game/debug\game.unsuccessfulbuild".
2>  Touching ".\./build/temp/game/debug\game.lastbuildstate".
2>
2>Build succeeded.
2>
2>Time Elapsed 00:00:12.75
========== Rebuild All: 1 succeeded, 0 failed, 2 skipped ==========

 grin grin grin finally.... i got it...

So, final step, i copy the gamex86.dll to the baseq2 file... double click... game... hard... loading... Some nice explotions and a broken spaceship by my side...

Thnx man... really thnx... finally i got it working... wouldnt be possible without your help... Now ill star working on the code, and try to understand it...

Later ill want to get the whole wuake2 build, but for now im done with the gamex86...

Again, thanx!

EDIT: and yeah, im on win7, visual c++ 2010...
Logged
QwazyWabbit
Member

Posts: 402


« Reply #13 on: October 25, 2010, 11:32:25 pm »

Congratulations, glad you got it working. There's more yet to do to get the engine compiling but the prinicples are the same.
Good luck on your modding. BTW, in order to debug the DLL you should also copy the PDB file along with the DLL or target the build to do it. You can configure the project to receive command line args to start a dedicated server with +set dedicated 1 +set game modname, etc. Then you can debug the server DLL and set breakpoints, printpoints etc. Connect to your debug server with a client as you would a network server (localhost), etc. No need to do SP or launch a listen server that way.
Logged
ravenwolf
Member

Posts: 31



« Reply #14 on: October 26, 2010, 04:05:51 pm »

Nice, for now i got no bugs, but ill try to do a debug anyway, so, if one come up, ill now how to debug the dll...

Thanx man, probably later ill try to build the entire project, so probably ill come with more questions, but for now, i got enougth with the dll, itll take me some time to fully master the code... thnx...
Logged
Pages: [1]
Print
r1ch.net  |  r1ch.net stuff  |  R1Q2  |  Topic: compile r1ch, original q2 src, or gamex86.dll using Dev-C++
Jump to:  

Powered by SMF 1.1.19 | SMF © 2013, Simple Machines