Compiling under VS2005/Older SDK:de

From Valve Developer Community
Jump to: navigation, search
English (en)Deutsch (de)русский (ru)
... Icon-Important.png
Info content.png
This page has not been fully translated.

You can help by finishing the translation.

Also, please make sure the article tries to comply with the alternate languages guide.

Achtung: Mittlerweile wurde eine Version des Source Codes mit dem SDK ausgeliefert, bei dem eine Projektdatei für VS2005 vorhanden ist. Dieser Artikel sollte also nichtmehr notwendig sein.

Seit November 2006 kompiliert das Source SDK einwandfrei unter VS 2005!


Visual Studio 2005 Express

Momentan funktioniert Visual C++ 2005 Express nicht mit dem SourceSDK Code, aber Valve arbeitet daran (laut Coding4Fun, auch wenn die "2-3 Monate" schon lang vorbei sind...).

Um dennoch zu compilen benutzt eben das folgende How-To.


Wie compile ich mit Visual Sudio 2005 / Visual C++ 2005 Express

Einführung

Hier also das Tutorial.

Zuallererst ist aufgeführt was, mit Hilfe dieses Tuts, schon funktioniert und was nicht. Unterteilt in SP, MP, und scratch source code.

Folgend die weiteren Voraussetzungen und wie man sie in VS einstellt.

Als nächstes das Fixing. Ein allgemeines, dann getrennt in Release und Debug.

ErrorFixes werden dargestellt wie folgt:

Datei(ZeilenNummer)

und wie die neue Zeile aussieht.

hf und bitte teil mir/uns mit ob es bei dir funktioniert und ich hoffe ich kann euch hiermit etwas helfen ;) User:Rotzi


Was funktioniert?

Hier eine Liste, was ist getestet und funktioniert:

SP:

  • Release - client - VS Studio: working but not playable -
  • Release - hl - VS Studio: working but not playable -
  • Debug - client - VS Studio: working but not playable - 826 warnings
  • Debug - hl - VS Studio: working but not playable - 1148 warnings
  • Release - client - V C++ Express: working but not playable - 33 warnings
  • Release - hl - V C++ Express: working but not playable - 42 warnings
  • Debug - client - V C++ Express: not tested yet
  • Debug - hl - V C++ Express: not tested yet

MP:

  • Release - client - V C++ Express: working & playable - 33 warnings
  • Release - hl - V C++ Express: working & playable - 42 warnings
  • none tested yet

scratch:

  • Release - client - V C++ Express: working - 33 warnings
  • Release - hl - V C++ Express: working - 42 warnings
  • not tested yet

Voraussetzungen

Schritte um mit V C++ 05 Express compilen zu können:

Benötigt:


Einstellen

Tools - Options: Projects and Solutions - VC++ Directories

rechts oben wähle "executable files" und füge ein: "...\Microsoft Platform SDK\Bin" (natürlich "..." mit deinem Pfad ersetzen)

"include files" --> "...\Microsoft Platform SDK\Include" und "...\Microsoft DirectX SDK (December 2005)\Include"

"libary files" --> "...\Microsoft Platform SDK\Lib" & "...\Microsoft DirectX SDK (December 2005)\Lib\x86"

Allgemein

Deprecated Declaration Warnings ausschalten/unterdrücken

Diese Warnungen warnen dich, dass du alte Funktionen verwendest, von denen es neuere gibt, die etwas sicherer/besser sind. Du willst aber erstmal nur compilen und noch nichts verändern, richtig? ;)

..\public\tier0\dbg.h

füge

#pragma warning(disable : 4996)

nach #pragma once (neue Zeile) ein.


wchar_t Linker errors

Linker errors mit wchar_t als Werte:

Client->;Properties->C/C++->Language
und setze 'Treat wchar_t as Built in Type' to 'No'.

Dieser Fehler entsteht wohl weil die Valve library vgui_control.lib auch mit 'Treat wchar_t as Built in Type' auf 'No' gestellt compiled wurde. Deshalb machen wir für unseren Code das Selbe.


error C2065: 'i' : undeclared identifier

Für den error C2065: 'i' : undeclared identifier gibt es 2 Lösungen. Für beide rechtsklicke auf client und hl, gehe auf C/C++ -> Language und wähle

'Force Conformance in For Loop' auf 'No'.

Alternativ kann man überall im Code "int"-Deklarationen einfügen wo sie fehlen.


Release-Compile

client&hl fixes

..\public\vstdlib\strtools.h(90):

inline char*	Q_strrchr (const char *s, char c)					{ return strrchr( (char *)s, c ); }

..\public\vstdlib\strtools.h(93) zu

inline char*	Q_strstr( const char *s1, const char *search )		{ return strstr( (char *)s1, search ); }

..\cl_dll\hud_bitmapnumericdisplay.cpp(159)

if( bStart || digit > 0 || pos <= pow((float)10,numSigDigits-1) )

..\game_shared\baseentity_shared.cpp(251)

char *s = strchr( (char *)szKeyName, '#' );

..\tier1\KeyValues.cpp(800)

char *subStr = strchr((char *)keyName, '/');


client fixes (client.dll)

Linking Errors & Fixes:

Added msvcrt.lib and user32.lib to Linker->Input->Additional Dependencies (separated each with a space(" "))

Added LIBC to Linker->Input->Ignore specific library

Added /FORCE:MULTIPLE to Linker->Command Line->Additional Options



hl fixes (server.dll)

..\dlls\vguiscreen.cpp(69)

char *s = strchr( (char *)szKeyName, '#' );

..\dlls\TemplateEntities.cpp(298)

int iMax = pow((double)10, (int)(strlen(ENTITYIO_FIXUP_STRING)-1)); // -1 for the &


changing function-run to function-link (error C3867)

..\dlls\hl2_dll\weapon_rpg.cpp (150)

SetTouch( &CMissile::MissileTouch );

(153)

SetThink( &CMissile::IgniteThink );

(256)

SetThink( &CMissile::SeekThink );

(311)

SetThink( &CMissile::AugerThink );

(435)

SetThink( &CMissile::SeekThink );

(881)

SetTouch( &CAPCMissile::APCMissileTouch );

(916)

SetThink( &CAPCMissile::BeginSeekThink );

(925)

SetThink( &CAPCMissile::AugerStartThink );

(938)

SetThink( &CMissile::AugerThink );

(945)

SetThink( &CAPCMissile::ExplodeThink );

(955)

SetThink( &CMissile::SeekThink );

(2058)

pLaserDot->SetContextThink( &CLaserDot::LaserThink, gpGlobals->curtime + 0.1f, g_pLaserDotThink );

..\dlls\hl2_dll\weapon_physcannon.cpp (2480)

SetContextThink( &CWeaponPhysCannon::WaitForUpgradeThink, gpGlobals->curtime + 6.0f, s_pWaitForUpgradeContext );

(2502)

SetContextThink( &CWeaponPhysCannon::WaitForUpgradeThink, gpGlobals->curtime + 0.1f, s_pWaitForUpgradeContext );

..\dlls\hl2_dll\weapon_crossbow.cpp(324)

SetThink( &CBaseEntity::SUB_Remove );

..\dlls\hl2_dll\npc_BaseZombie.cpp(160) : fixed error C4430

static int s_iAngryZombies = 0;

..\dlls\baseentity.cpp(57): fixed error C3861: "tolower"

add

#include <ctype.h>

after #include "vphysics/friction.h" (L 57) to the next line (so basically between line 57 and line 58)


Linking Errors & Fixes:

Added user32.lib to Additional Dependencies under Linker->Input

Added /FORCE:MULTIPLE to Linker->Command Line->Additional Options



Debug-Compile:

client:

...\public\tier0\memoverride.cpp line 405-430 (410-435 wenn du obige Funktionen eingefügt hast (release hl, andere fixes?))

Entferne "_base" von jeder dieser Funktionen und füge sie an die return-Var. Sieht dann so aus:

  • (406/411)
void    __cdecl _aligned_free(
  • (410/415)
void *  __cdecl _aligned_malloc(
  • (415/420)
void * __cdecl _aligned_malloc_base(
  • (420/425)
    return _aligned_malloc(size, align);
  • (423/428)
void __cdecl _aligned_free_base(
  • (427/432)
    _aligned_free(memblock);


Linking Errors & Fixes:

Added msvcrtd.lib and user32.lib Linker->Input->Additional Dependencies

Added /FORCE:MULTIPLE to Linker->Command Line->Additional Options


hl:

...\dlls\ai_behavior_follow.cpp(2090)

//ASSERT_INVARIANT( sizeof(FollowerListIter_t) == sizeof(AI_FollowManagerInfoHandle_t) );


Linking Errors & Fixes:

Added user32.lib to Linker->Input->Additional Dependencies

Added /FORCE:MULTIPLE to Linker->Command Line->Additional Options

Andere Fixes

Bemerkung: Am Ende habe ich diese nicht gebraucht, glaube ich... (Deshalb auch erstma nich übersetzt... braucht es also nicht für Release Comp.)

The problem with strdup doesn't happen in debug mode since Valve overrides strdup with their own strdup func. The heap error only shows itself when using the debugger in release mode. I believe it's because strdup() in the C library that comes with 2005 express uses new() instead of malloc(). So when Valve frees the memory using free() it gives the error. Here's the fix I hope...

..\tier1\stringpool.cpp(73)

CHANGE

	pszNew = strdup( pszValue );

TO

	#ifndef _debug
		pszNew = (char*) malloc(sizeof(char) * (strlen(pszValue) + 1)); // Use Valve's malloc instead of strdup
		strcpy(pszNew, pszValue);
	#else
		pszNew = strdup( pszValue ); // Use Valve's debug strdup
	#endif


..\cl_dll\c_baseflex.cpp(921)

CHANGE

	g_flexcontroller[g_numflexcontrollers++] = strdup( szName );

TO

		#ifndef _debug
			g_flexcontroller[g_numflexcontrollers] = (char*) malloc(sizeof(char) * (strlen(szName) + 1)); //Use V's malloc instead of strdup
			strcpy(g_flexcontroller[g_numflexcontrollers++], szName);
		#else
			g_flexcontroller[g_numflexcontrollers++] = strdup( szName ); //Use V's debug strdup
		#endif


BotPutInServer linker failures (worked for me, didn't have to do this with SP)

Various BotPutInServer lines will fail to link in DEBUG mode. Commenting the BotPutInServer lines out works just fine. It may have some negative affect on bots. I quite frankly have not looked into that stuff at all, other than to see that it breaks the build.

Fix: A better way would be

	adding hl2mp_bot_temp.h and hl2mp_bot_temp.cpp 
	to the HL project under the Source Files->HL2MP folder.
	hl2mp_bot_temp.h and hl2mp_bot_temp.cpp can both be found in yourmod/src/dlls/hl2mp_dll folder.



to fix some warnings:

..\public\tier0\memoverride.cpp

  • (107)
__declspec(restrict) __declspec(noalias) void *malloc( size_t nSize ) 
  • (111)
__declspec(noalias) void free( void *pMem ) 
  • (116)
__declspec(restrict) __declspec(noalias) void *realloc( void *pMem, size_t nSize ) 
  • (121)
__declspec(restrict) __declspec(noalias) void *calloc( size_t nCount, size_t nElementSize )
  • add this function to line 136 (i don't get what this is for???)
void *_calloc_impl( size_t nCount, size_t nElementSize )
{
return calloc(nCount, nElementSize);
} 

comment out _heap_init() and _heap_term(), means, (i don't get what this is for???)

comment out everything from line 298 to line 303 (these lines are these lines if you added the function *_calloc_impl (which is 4 lines long) to line 136.

Compiliert aber Errors Liste

Hier liste ich ein paar Fehler auf die damit noch nicht gefixt sind. Auch wenn ich nicht immer weiß ob sie gefixt werden sollten oder ob es egal ist.

SP Debug Client

..\public\tier0\commonmacros.h(29) : warning C4005: 'ARRAYSIZE': Makro-Neudefinition
pathto\microsoft platform sdk\include\winnt.h(950): Siehe vorherige Definition von 'ARRAYSIZE'

..\public\tier0\memoverride.cpp(413)(418)(418) : warning C4565 (Das sollte zu fixen sein, ohne Probs...)

LINK : warning LNK4075: ignoring /INCREMENTAL due to /FORCE specification.

LANGE Liste von .obj Dateien, alle mit dieser Warnung:

warning LNK4224: /COMMENT is no longer supported; ignored.

msvcrt.lib(MSVCR80.dll) : warning LNK4006: _free already defined in "memoverride.obj"; second definition ignored

.\cl_dll___Win32_HL2_Debug/client.dll : warning LNK4088: image being generated due to /FORCE option; image may not run.


SP Debug hl

..\public\tier0\memdbgon.h(83) : warning C4996: 'strcpy' (Kann so bleiben...)

same for 'wcscpy' and 'strtok'

+einige neue Doppel-Definitionen (LIBCMTD.lib, ...)

+die Fehler vom SP Debug Client (LNK4224: /COMMENT, warning C4005: 'ARRAYSIZE')

Related Articles