.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Programming
General Programming Help others and get yourself helped here!

Reply
 
Thread Tools
compiling .c and .cpp files altogether ?
Old
  (#1)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default compiling .c and .cpp files altogether ? - 13-12-2004

I've realized my old dream: porting all my bot source code to ANSI C. It's now all .c files, at the exception of interface.cpp which contains the HL engine interfacing functions and stuff.

But the problem, is that the linker can't seem to find external variables and functions in both situations! I mean that when something is declared in a .c file it can't be accessed from the .cpp file (even if you declare it extern) and vice versa...

look at the output
Quote:
--------------------Configuration: HL:CounterStrike - Win32 Release--------------------
Compiling resources...
Compiling...
bmpfile.c
dxffile.c
mapdata.c
pathmachine.c
console.c
display.c
lrand.c
math.c
mfile.c
util.c
bot.c
bot_cognition.c
bot_combat.c
bot_start.c
interface.cpp
bot_body.c
bot_chat.c
bot_ears.c
bot_eyes.c
bot_navigation.c
weapons.c
Updating resources...
Linking...
Creating library ..\../racc.lib and object ..\../racc.exp
mapdata.obj : error LNK2001: unresolved external symbol _PointBelongsToWorld
bot_body.obj : error LNK2001: unresolved external symbol _PointBelongsToWorld
mapdata.obj : error LNK2001: unresolved external symbol _PlayerTestHull
util.obj : error LNK2001: unresolved external symbol _PlayerTestHull
bot_body.obj : error LNK2001: unresolved external symbol _PlayerTestHull
mapdata.obj : error LNK2001: unresolved external symbol _PlayerTestLine
bot_body.obj : error LNK2001: unresolved external symbol _PlayerTestLine
bot_eyes.obj : error LNK2001: unresolved external symbol _PlayerTestLine
bot_navigation.obj : error LNK2001: unresolved external symbol _PlayerTestLine
bot_navigation.obj : error LNK2001: unresolved external symbol _TestVisibility
mapdata.obj : error LNK2001: unresolved external symbol _TestVisibility
util.obj : error LNK2001: unresolved external symbol _TestVisibility
bot_combat.obj : error LNK2001: unresolved external symbol _TestVisibility
bot_eyes.obj : error LNK2001: unresolved external symbol _TestVisibility
util.obj : error LNK2001: unresolved external symbol _IsLiquid
bot_body.obj : error LNK2001: unresolved external symbol _IsLiquid
bot_navigation.obj : error LNK2001: unresolved external symbol _IsLiquid
bot.obj : error LNK2001: unresolved external symbol _FindMaterialType
bot_ears.obj : error LNK2001: unresolved external symbol _FindMaterialType
interface.obj : error LNK2001: unresolved external symbol "char * racc_version" (?racc_version@@3PADA)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl DllAttaching(void)" (?DllAttaching@@YAXXZ)
interface.obj : error LNK2001: unresolved external symbol "struct server_s Server" (?Server@@3Userver_s@@A)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl DllDetaching(void)" (?DllDetaching@@YAXXZ)
interface.obj : error LNK2001: unresolved external symbol "struct entity_s * entities" (?entities@@3PAUentity_s@@A)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl PlayClientSoundsForBots(struct player_s *)" (?PlayClientSoundsForBots@@YAXPAUplayer_s@@@Z)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl ShowTheWayAroundToBots(struct player_s *)" (?ShowTheWayAroundToBots@@YAXPAUplayer_s@@@Z)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl BotAct(struct player_s *)" (?BotAct@@YAXPAUplayer_s@@@Z)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl BotThink(struct player_s *)" (?BotThink@@YAXPAUplayer_s@@@Z)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl BotSense(struct player_s *)" (?BotSense@@YAXPAUplayer_s@@@Z)
interface.obj : error LNK2001: unresolved external symbol "float __cdecl RandomFloat(float,float)" (?RandomFloat@@YAMMM@Z)
interface.obj : error LNK2001: unresolved external symbol "int player_count" (?player_count@@3HA)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl BotCreate(struct player_s *)" (?BotCreate@@YAXPAUplayer_s@@@Z)
interface.obj : error LNK2001: unresolved external symbol "struct profile_s * __cdecl FindUnusedBotProfile(void)" (?FindUnusedBotProfile@@YAPAUprofile_s@@XZ)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl BotHALSaveBrain(struct player_s *)" (?BotHALSaveBrain@@YAXPAUplayer_s@@@Z)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl BotNavSaveBrain(struct player_s *)" (?BotNavSaveBrain@@YAXPAUplayer_s@@@Z)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl BotReset(struct player_s *)" (?BotReset@@YAXPAUplayer_s@@@Z)
interface.obj : error LNK2001: unresolved external symbol "unsigned char __cdecl VectorIsNull(struct vec_s)" (?VectorIsNull@@YAEUvec_s@@@Z)
interface.obj : error LNK2001: unresolved external symbol "struct entity_s * __cdecl FindEntityByString(struct entity_s *,char,char const *)" (?FindEntityByString@@YAPAUentity_s@@PAU1@DPBD@Z)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl APlayerHasConnected(struct player_s *)" (?APlayerHasConnected@@YAXPAUplayer_s@@@Z)
interface.obj : error LNK2001: unresolved external symbol "float __cdecl DistanceBetween(struct vec_s,struct vec_s)" (?DistanceBetween@@YAMUvec_s@@0@Z)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl TerminateOnError(char const *,...)" (?TerminateOnError@@YAXPBDZZ)
interface.obj : error LNK2001: unresolved external symbol "struct weapon_s * __cdecl FindPlayerWeaponByModel(struct player_s *,char const *)" (?FindPlayerWeaponByModel@@YAPAUweapon_s@@PAUplayer _s@@PBD@Z)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl BuildPlayerReferential(struct vec_s,struct player_s *)" (?BuildPlayerReferential@@YAXUvec_s@@PAUplayer_s@@@ Z)
interface.obj : error LNK2001: unresolved external symbol "struct player_s * pListenserverPlayer" (?pListenserverPlayer@@3PAUplayer_s@@A)
interface.obj : error LNK2001: unresolved external symbol "float __cdecl WrapAngle(float)" (?WrapAngle@@YAMM@Z)
interface.obj : error LNK2001: unresolved external symbol "struct vec_s __cdecl VectorSubstract(struct vec_s,struct vec_s)" (?VectorSubstract@@YA?AUvec_s@@U1@0@Z)
interface.obj : error LNK2001: unresolved external symbol "struct mission_s Mission" (?Mission@@3Umission_s@@A)
interface.obj : error LNK2001: unresolved external symbol "float __cdecl ProcessTime(void)" (?ProcessTime@@YAMXZ)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl TheServerHasJustStarted(void)" (?TheServerHasJustStarted@@YAXXZ)
interface.obj : error LNK2001: unresolved external symbol "void * __cdecl SAFE_Z_malloc(unsigned int)" (?SAFE_Z_malloc@@YAPAXI@Z)
interface.obj : error LNK2001: unresolved external symbol "struct game_config_s GameConfig" (?GameConfig@@3Ugame_config_s@@A)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl SAFE_free(void *)" (?SAFE_free@@YAXPAX@Z)
interface.obj : error LNK2001: unresolved external symbol "void * __cdecl SAFE_realloc(void *,unsigned int)" (?SAFE_realloc@@YAPAXPAXI@Z)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl APlayerHasDisconnected(struct player_s *)" (?APlayerHasDisconnected@@YAXPAUplayer_s@@@Z)
interface.obj : error LNK2001: unresolved external symbol "struct player_s * players" (?players@@3PAUplayer_s@@A)
interface.obj : error LNK2001: unresolved external symbol "struct debug_level_s DebugLevel" (?DebugLevel@@3Udebug_level_s@@A)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl DispatchSound(char const *,struct vec_s,float,float)" (?DispatchSound@@YAXPBDUvec_s@@MM@Z)
interface.obj : error LNK2001: unresolved external symbol "char const * __cdecl GetField(char const *,int)" (?GetField@@YAPBDPBDH@Z)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl PlayBulletSoundsForBots(struct player_s *)" (?PlayBulletSoundsForBots@@YAXPAUplayer_s@@@Z)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl BotFeedEar(struct player_s *,struct sound_s *,struct vec_s,float)" (?BotFeedEar@@YAXPAUplayer_s@@PAUsound_s@@Uvec_s@@M @Z)
interface.obj : error LNK2001: unresolved external symbol "struct sound_s * __cdecl FindSoundByFilename(char const *)" (?FindSoundByFilename@@YAPAUsound_s@@PBD@Z)
interface.obj : error LNK2001: unresolved external symbol "char * __cdecl UpperCase(char const *)" (?UpperCase@@YAPADPBD@Z)
interface.obj : error LNK2001: unresolved external symbol "int __cdecl ServerConsole_printf(char const *,...)" (?ServerConsole_printf@@YAHPBDZZ)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl BotIssueClientCommand(struct player_s *,char const *,...)" (?BotIssueClientCommand@@YAXPAUplayer_s@@PBDZZ)
interface.obj : error LNK2001: unresolved external symbol "void __cdecl BotSetIdealYaw(struct player_s *,float)" (?BotSetIdealYaw@@YAXPAUplayer_s@@M@Z)
interface.obj : error LNK2001: unresolved external symbol "char * racc_welcometext" (?racc_welcometext@@3PADA)
interface.obj : error LNK2001: unresolved external symbol "long __cdecl RandomLong(long,long)" (?RandomLong@@YAJJJ@Z)
interface.obj : error LNK2001: unresolved external symbol "int __cdecl ServerCommand(int,char * *)" (?ServerCommand@@YAHHPAPAD@Z)
interface.obj : error LNK2001: unresolved external symbol "char const * __cdecl TeamNameOf(struct player_s *)" (?TeamNameOf@@YAPBDPAUplayer_s@@@Z)
bot_chat.obj : error LNK2001: unresolved external symbol _PlayerStopTalking
bot_chat.obj : error LNK2001: unresolved external symbol _PlayerStartTalking
bot_eyes.obj : error LNK2001: unresolved external symbol _GetBonePosition
bot_navigation.obj : error LNK2001: unresolved external symbol _IsThinAir
..\../racc.dll : fatal error LNK1120: 60 unresolved externals
Error executing link.exe.
racc.dll - 74 error(s), 0 warning(s)
Does anybody have an explanation ? Don't tell me it's impossible, argh... no...



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: compiling .c and .cpp files altogether ?
Old
  (#2)
sfx1999
Member
 
sfx1999's Avatar
 
Status: Offline
Posts: 534
Join Date: Jan 2004
Location: Pittsburgh, PA, USA
Default Re: compiling .c and .cpp files altogether ? - 13-12-2004

Maybe you have to wrap your C files like this:

Code:
#ifdef cplusplus
    extern "C"
    {
    #endif
    
    //the code
    
    #ifdef cplusplus
     }
     #endif


sfx1999.postcount++
  
Reply With Quote
Re: compiling .c and .cpp files altogether ?
Old
  (#3)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: compiling .c and .cpp files altogether ? - 13-12-2004

sfx I love you!

erm, right. In the very spiritual sense of the term, I mean

btw, it's not cplusplus but __cplusplus.



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: compiling .c and .cpp files altogether ?
Old
  (#4)
sfx1999
Member
 
sfx1999's Avatar
 
Status: Offline
Posts: 534
Join Date: Jan 2004
Location: Pittsburgh, PA, USA
Default Re: compiling .c and .cpp files altogether ? - 13-12-2004

I put cplusplus. So, it worked then?


sfx1999.postcount++
  
Reply With Quote
Re: compiling .c and .cpp files altogether ?
Old
  (#5)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: compiling .c and .cpp files altogether ? - 13-12-2004

Yeah, but instead of wrapping all the .c files with it, I only needed to wrap the function prototypes and the global variables declarations. All the rest can remain unchanged.

Thanks for the hint, anyway



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: compiling .c and .cpp files altogether ?
Old
  (#6)
sfx1999
Member
 
sfx1999's Avatar
 
Status: Offline
Posts: 534
Join Date: Jan 2004
Location: Pittsburgh, PA, USA
Default Re: compiling .c and .cpp files altogether ? - 13-12-2004

Well, I had no clue if it was going to work or not, but I remembered it was in Botman's patches for GCC.


sfx1999.postcount++
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com