Talk:Compiling under VS2005: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(→‎Compiled but Errors List: - added SP Debug hl errors)
m (Not much need to screenshot this)
 
(82 intermediate revisions by 39 users not shown)
Line 1: Line 1:
== How to Compile with Visual C++ 2005 Express ==
* [[Talk:Compiling under VS2005/20090316|Archive 2009/03/16]]


===Intro===
== Visual C++ Express 2005 Directories Setup ==


So, here is a Step-by-Step how-to compile the SDK Source Code.
After installing the Microsoft Windows (Platform) SDK, when setting up the directories in Visual C++ Express 2005 do you need to add "Source Files"?? It has one entry:


First, there's a list of what has been tested and is working with this tutorial, or wich is not. Seperated in SP, MP, and scratch source code.
$(VCInstallDir)crt\src


Then there are the requirements, things you need besides the Source SDK and MS Visual, and how to set them up in your VS.
I found this directory in the Platform SDK:


Next comes the error fixing. A general, and then seperated into ''Release'' and ''Debug'' building.
C:\Program Files\Microsoft Platform SDK\src\crt


ErrorFixes will be stated as: file(line number)
Just curious if it needs to be added.
and how the new line looks


hf and plz tell me/us if it works for you, and I hope I could help you with this... [[User:Rotzi]]
== ==
OK, looks like I Googled for nothing, so I'm going to warn you guys now, if your getting errors, look in this page, because I Googled for 2 hours, just to be lead back to the page I started on, but at least it all works now, I'm glad for that. In conclusion, make sure you aren't looking at the fix before you Google for it...


== PRJ0019 ==


====What's Working?====
When I Build my Mod (Debug), I get this error:


Here's a list of what is tested and working:
SP:
*Release - client - VS Studio: working
*Release - hl - VS Studio: working
*Debug - client - VS Studio: working - 826 warnings
*Debug - hl - VS Studio: working - 1148 warnings


*Release - client - VS Express: not tested yet
echo Project : error PRJ0019: A tool returned an error code from "Copying to c:\program files\steam\steamapps\SourceMods\hunternavan\bin\"
*Release - hl - VS Express: not tested yet
*Debug - client - VS Express: not tested yet
*Debug - hl - VS Express: not tested yet
MP:
*none tested yet
scratch:
*none tested yet


==== Requirements (other SDKs and Setup of those) ====
What do I do? --[[User:Adam.gamedev|Adam.gamedev]] 17:45, 12 July 2010 (UTC)


steps till being able to compile with V C++ 05 Express:
== gameinfo.txt ==


required:
When I Debug my Mod, I get this error:
  Setup file 'gameinfo.txt' doesn't exist in subdirectory 'hl2'.
  Check your -game paremeter or VCONFIG setting.


*[http://msdn.microsoft.com/directx/sdk/ MS DirectX SDK]
What do I do? --[[User:Adam.gamedev|Adam.gamedev]] 19:33, 12 July 2010 (UTC)
*MS Platform SDK
 
 
''setup''
 
Tools - Options: Projects and Solutions - VC++ Directories
 
upper right select "executable files" and enter "...\Microsoft Platform SDK\Bin" (replace ... with your path of course)
 
"include files" --> "...\Microsoft Platform SDK\Include" and "...\Microsoft DirectX SDK (December 2005)\Include"
 
"libary files" --> "...\Microsoft Platform SDK\Lib" & "...\Microsoft DirectX SDK (December 2005)\Lib\x86"
 
 
=== General: Disabling Deprecated Declaration Warnings  ===
 
With this fix you will disable the deprecated declaration warnings, wich indeed is only a warning.
 
It warns you that the used functions are old ones and there are new, more secure versions. But you just wanna compile, you don't want to edit/improve code yet, right? ;)
 
..\public\tier0\'''dbg.h'''
 
add
#pragma warning(disable : 4996)
after #pragma once (new line) to disable old, unsecure functions warning.
 
 
 
===Release-Compile:===
 
'''client:'''
 
..\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, '/');
 
 
''Linking Errors & Fixes:''
 
Added msvcrt.lib and user32.lib to Linker->Input->Additional Dependencies (seperated each with a space(" "))
 
Added LIBC to Linker->Input->Ignore specific library
 
Added /FORCE:MULTIPLE to Linker->Command Line->Additional Options
 
 
-----------
'''hl:'''
 
..\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;
 
''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 if you added functions above (release hl))
 
Remove "_base" from those functions and add it to return-var. Looks then like this:
 
*(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
 
===Other Fixes===
 
I'm just trying out these...
 
For tolower() error:
 
baseentity.cpp(57)
 
add #include <ctype.h>
 
after #include "vphysics/friction.h" (L 57)
 
 
Linker errors with wchar_t as values:
 
Client->;Properties->C/C++->Language
and set Treat wchar_t as Built in Type to No.
 
This is because the Valve library vgui_control.lib is compiled with the option - Treat wchar_t as Built in Type - set to No so they need to be the same.
 
An alternative fix is to recompile vgui_control.lib with the option set to Yes - its found in src\vgui2\controls. So you need to back up vgui_control.lib - found in src\lib\public and recompile it with the option set to yes and then copy that to where the original one was that you backed up.
 
 
For the error C2065: 'i' : undeclared identifier. There are two ways to fix this.
 
Easiest way is to go to Client->;Properties->C/C++->Language and set
Force Conformance in For Loop to No.
 
Alternative fix would be adding the "int"-declaration into code. That's how i did it before and how it's described above.
 
 
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
 
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 (wich is 4 lines long) to line 136.
 
===Other Fixes / Comments===
 
got some info from [http://www.chatbear.com/board.plm?a=viewthread&t=104,1102070328,6443&b=4991&id=949052&v=flatold&s=0 this forumthreat]
 
i had some errors in c_rope
 
fixed it once with:
 
taking the closing "}" from ''( int iRenderCache = 0; iRenderCache < nRenderCacheCount; ++iRenderCache )''
 
behind ''++m_aRenderCache[iRenderCache].m_nCacheCount;''
 
(means from line 231 (i think) to line 252)
 
i'm still trying to complete this so it will compile, hope i could help anyone...
 
greetz
 
[[User:Rotzi]] Jan 2006
 
 
grml...
 
doesn't work neither with express nor with full version... maybe i'm just stupid...
 
I'll try again this weekend and update here...
 
[[User:Rotzi]] Feb 2006
 
 
And still I'm having problems... Just tried it again, Release Client only, but did not get past 3 kinds of errors, wich all in all were 190 errors and 439 warnings...
 
I also noticed that including user32.lib and excluding LIBC did not change these error-numbers, so atleast up to that point, it did not need them... Still I'm only talking about client-Release Only.
 
[[User:Rotzi]]
 
----
 
No longer needed, just if i/we need it again... ;)
'undeclared variable'
..\cl_dll\interpolatedvar.h(538)
..\public\sentence.cpp(735)
..\public\sentence.cpp(1098)
..\public\sentence.cpp(1168)
 
----
 
===Compiled but Errors List===
 
Here I'll add the warning not fixed yet. Though i don't always know whether it should be fixed or doesn't matter.
 
====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 (I should be able to fix that, will check that again later...)
 
LINK : warning LNK4075: ignoring /INCREMENTAL due to /FORCE specification.
 
LONG LIST of .obj files, all with warning:
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' (can stay like that...)
same for 'wcscpy' and 'strtok'
 
+some new double-definitions (LIBCMTD.lib, ...)
 
+the errors of SP Debug Client (LNK4224: /COMMENT, warning C4005: 'ARRAYSIZE')
 
== Misc ==
I'll be getting a copy of Visual Studio 2005 (not express) in the next couple of weeks. Is there a problem compiling on it too or does anybody know yet? --[[User:AndrewNeo|AndrewNeo]] 07:11, 28 Jan 2006 (PST)
 
No, what i read is there are no Problems with normal, full Version of VS 05. --[[User:Rotzi|Rotzi]] 4 Fe 2006 (GMT+1)
 
 
''' Force:Multiple error in release - client '''
 
How come i get the error like described in the threat, but it won't be fixed by adding "/FORCE:MULTIPLE", but caused by that instead... caused means, without it it doesn't get to that error, or doesn't have it...
 
msvcrt.lib(MSVCR80.dll) : error LNK2005: _free already defined in memoverride.obj ''(thats the error)''
 
Added /FORCE:MULTIPLE to Linker->Command Line->Additional Options ''(and that should be the solution)''

Latest revision as of 23:30, 17 July 2011

Visual C++ Express 2005 Directories Setup

After installing the Microsoft Windows (Platform) SDK, when setting up the directories in Visual C++ Express 2005 do you need to add "Source Files"?? It has one entry:

$(VCInstallDir)crt\src

I found this directory in the Platform SDK:

C:\Program Files\Microsoft Platform SDK\src\crt

Just curious if it needs to be added.

OK, looks like I Googled for nothing, so I'm going to warn you guys now, if your getting errors, look in this page, because I Googled for 2 hours, just to be lead back to the page I started on, but at least it all works now, I'm glad for that. In conclusion, make sure you aren't looking at the fix before you Google for it...

PRJ0019

When I Build my Mod (Debug), I get this error:


echo Project : error PRJ0019: A tool returned an error code from "Copying to c:\program files\steam\steamapps\SourceMods\hunternavan\bin\"

What do I do? --Adam.gamedev 17:45, 12 July 2010 (UTC)

gameinfo.txt

When I Debug my Mod, I get this error:

 Setup file 'gameinfo.txt' doesn't exist in subdirectory 'hl2'.
 Check your -game paremeter or VCONFIG setting.

What do I do? --Adam.gamedev 19:33, 12 July 2010 (UTC)