Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Building the code...

  1. Registered TeamPlayer
    Join Date
    10-29-07
    Posts
    4,953
    Post Thanks / Like
    Stat Links

    Building the code...
    #1

    Building the code...

    You only need to build anything if your going to rebuild the .dll itself, which you don't need to do if you're just editing the python files.

    One of the beauties of python is that you just edit it, and then run it; there is no build step. Now the first time it's run, the python interpreter will compile it (.py->.pyc), but that's automatic and you never have to deal with that directly. Just edit the python files, copy them to your dedicated server instance, and then start your server.

    Now if you really want to rebuild the dll, it involves getting both MSVS 2008 Express Edition (see this thread), downloading metamod:source, downloading the hl2 sdk, setting up some environment variables to point at where you put metamod and the sdk, and then finally doing the build. It's involved and it's easy to get wrong, which is why I'm trying to make it so that nobody has to rebuild the dll. Just reuse the one in the download and then add features by editing the python files. I ported the mod to python so we wouldn't have to rebuild the dll just to add a new feature. So much can be done straight from python without touching the C++ code at all.

    If you still want to build the dll, read on.

    Here are subversion links to checking out all if the metamod and sdk code you need. Give these links to your subversion client to be able to check out the code. If your new to subversion, go install TortoiseSVN here and and search for some tutorials on Google.

    Here are a few tutorials I found quickly:
    https://www.projects.dev2dev.bea.com...rtoiseSVN.html
    http://www.wdogsystems.com/opencms/o...rtoisesvn.html



    HL2 Original SDK:
    svn://svn.alliedmods.net/svnroot/sourcemm/hl2sdk

    HL2 OrangeBox SDK:
    svn://svn.alliedmods.net/svnroot/sourcemm/hl2sdk-ob

    Metamod:Source for Original engine:
    svn://svn.alliedmods.net/svnroot/sourcemm/tags/sourcemm-1.4.3

    Metamod:Source for OrangeBox engine:
    svn://svn.alliedmods.net/svnroot/sourcemm/tags/sourcemm-1.6.1

    You need both SDKs and both metamod's: original to build for CSS and DODS, and orangebox to build for TF2

    My development directory looks like:
    Code:
    sourcedev/
         hl2sdk/
         hl2sdk-ob/
         sourcemm14/
         sourcemm16/
         lonestar/
    And I have 4 environment variables (needed for the IDE to know where you put the above)
    Code:
    HL2SDK=C:\sourcedev\hl2sdk
    HL2SDKOB=C:\sourcedev\hl2sdk-ob
    SOURCEMM14=C:\sourcedev\sourcemm14
    SOURCEMM16=C:\sourcedev\sourcemm16
    To add environment variables to your computer: Right click "My Computer"->Manage->Advanced->Environment Variables
    Then for each variable you want (each of the 4 above), you click the New button under System Variables and fill out the two fields that pop up. If you were making the first environment variable, name would be "HL2SDK" and value would be "C:\sourcedev\hl2sdk".



    If you have questions or comments, feel free to post them up


  2. Registered TeamPlayer
    Join Date
    06-02-07
    Posts
    173
    Post Thanks / Like
    #2

    Re: Building the code...

    How do you properly link the Python libs? The python headers were not included lonestar source .zip, and trying to link directly to my python installation is giving me linker errors:

    Code:
    LINK : fatal error LNK1104: cannot open file 'python25.lib'

  3. Registered TeamPlayer
    Join Date
    10-29-07
    Posts
    4,953
    Post Thanks / Like
    Stat Links

    Building the code...
    #3

    Re: Building the code...

    Hmm sorry I forgot to talk about it in the above post.

    Ok the short answer is you have to download the source code of python from www.python.org, tweak it a little, and then build it. You then statically link that custom built version of python into lonestar.

    In the source of lonestar, there is a python directory. In it you'll find a couple of files. The most important is LONESTAR-MODIFICATIONS.txt, which tells you how to tweak the standard python source and what to do with the other files in the python directory.

    Here are some more spelled out directions:
    1) Get python source: http://www.python.org/ftp/python/2.5...-2.5.2.tar.bz2
    2) Extract it to lonestar\python (i.e. python's LICENSE file should now be at lonestar\python\LICENSE)
    3) Overwrite lonestar\python\Include\pythonrun.h with lonestar\python\pythonrun.h
    4) Overwrite lonestar\python\PC\getpathp.c with lonestar\python\getpathp.c
    5) Open lonestar\python\PCbuild8\pcbuild.sln in Visual Studio Express Edition 2008 (you'll get an error about something express edition doesn't support, but just click through it, it doesn't matter)
    6) Right click on the "pythoncore" project and select properties
    7) Make sure the Release configuration is selected
    8 ) Change Configuration Properties => General => Configuration Type to "Static Library"
    9) Change Configuration Properties => C/C++ => Code Generation => Runtime Library to "Multi-threaded (/MT)"
    10) Click "OK" to close this configuration dialog
    11) Make sure the Release configuration is selected at the top of the IDE so that our build is a Release build
    12) Right click on "pythoncore" and select build (we want to build only pythoncore and it's two dependancies, not everything in the source distribution).
    13) Rebuild lonestar. Unless you changed the settings in the lonestar project, it should automatically find the python headers and libraries under lonestar/python and use those. If you did change the project, either change it back or just overwrite your changed version of the project with the original version.


  4. Registered TeamPlayer
    Join Date
    06-02-07
    Posts
    173
    Post Thanks / Like
    #4

    Re: Building the code...

    Ok, everything worked fine up to the last step, but still getting a nearly identical linker error:

    Code:
    LINK : fatal error LNK1181: cannot open input file 'python25.lib'
    The compiled lib was put in python\PCbuild8\Win32Release by default, which I don't see in the include paths... is that a problem?

  5. Registered TeamPlayer
    Join Date
    10-29-07
    Posts
    4,953
    Post Thanks / Like
    Stat Links

    Building the code...
    #5

    Re: Building the code...

    This:
    Configuration Properties => Linker => General => Additional Library Directories

    Should be set to:
    "$(SolutionDir)..\python\PCbuild8\Win32Release "

    If it's not, that would explain the problem.

    Also make sure your editing the "Release" configuration

  6. Registered TeamPlayer
    Join Date
    06-02-07
    Posts
    173
    Post Thanks / Like
    #6

    Re: Building the code...

    After looking a little more carefully, this is the issue: lonestar wants python25.lib, but I built pythoncore.lib. For now I renamed the output file, and the two release configurations compile, but the lonestar.dll build fails in the debug configurations with four errors like this one:

    Code:
    lonestar.obj : error LNK2001: unresolved external symbol __Py_RefTotal

  7. Registered TeamPlayer
    Join Date
    10-29-07
    Posts
    4,953
    Post Thanks / Like
    Stat Links

    Building the code...
    #7

    Re: Building the code...

    python25.lib isn't the same as pythoncore.lib; you really need python25.lib. I thought for sure the pythoncore project also built python25.lib. I'll have to check it when I get home today.

  8. Registered TeamPlayer
    Join Date
    10-29-07
    Posts
    4,953
    Post Thanks / Like
    Stat Links

    Building the code...
    #8

    Re: Building the code...

    Ok what does your "pythoncore" project have for:
    Configuration Properties => Librarian => General => Output File

    Mine says:
    $(OutDir)\$(PyDllName).lib

    which (once expanded) turns into:
    C:\sourcedev\lonestar2\python\PCbuild8\Win32Releas e\python25.lib
    (you can see what it expands to for you by looking at Configuration Properties => Librarian => Command Line)


    If it's not "$(OutDir)\$(PyDllName).lib" try changing it to that and rebuilding "pythoncore"

  9. Registered TeamPlayer
    Join Date
    06-02-07
    Posts
    173
    Post Thanks / Like
    #9

    Re: Building the code...

    Yeah looks like my project just had a different output file name, was set to
    $(OutDir)\$(ProjectName).lib

    I changed it and rebuilt, and again the two release configurations of lonestar compile but the debug configurations complain of "unresolved external symbols". Here's the full build log from one of these:

    Code:
    1>------ Build started: Project: lonestar, Configuration: Debug - Episode 1 Win32 ------
    1>Linking...
    1>python25.lib(stringobject.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
    1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification
    1>  Creating library C:\sourcedev\lonestar\msvs9\Debug - Episode 1\lonestar.lib and object C:\sourcedev\lonestar\msvs9\Debug - Episode 1\lonestar.exp
    1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
    1>lonestar.obj : error LNK2001: unresolved external symbol __Py_RefTotal
    1>lonestar.obj : error LNK2001: unresolved external symbol __Py_Dealloc
    1>lonestar.obj : error LNK2001: unresolved external symbol __Py_NegativeRefcount
    1>lonestar.obj : error LNK2001: unresolved external symbol _Py_InitModule4TraceRefs
    1>C:\sourcedev\lonestar\msvs9\Debug - Episode 1\lonestar.dll : fatal error LNK1120: 4 unresolved externals
    1>Build log was saved at "file://c:\sourcedev\lonestar\msvs9\lonestar\Debug - Episode 1\BuildLog.htm"
    1>lonestar - 5 error(s), 2 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    This suggests to me that the problem has to do with trying to mix a release version of python25.lib with a debug compile of lonestar, but I don't know enough to say for sure.

  10. Registered TeamPlayer
    Join Date
    10-29-07
    Posts
    4,953
    Post Thanks / Like
    Stat Links

    Building the code...
    #10

    Re: Building the code...

    Ok I totally missed that it's the debug builds that are failing.

    Just as an FYI, it's problematic to use a debugger on a mod, so the debug build doesn't really get you anything. So, I actually only build and use the release builds. And because of that, I only properly setup the release configurations in the project files. So the debug project configurations for both lonestar and python that your trying to build are probably just out of date and broken.

    But since you can build the releases, your set

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Title