Help with a Linker Error Created 3 years ago2021-03-24 01:10:28 UTC by Pezus Pezus

Created 3 years ago2021-03-24 01:10:28 UTC by Pezus Pezus

Posted 3 years ago2021-03-24 01:10:28 UTC Post #345474
Hey there, I'm trying to make a Deagle but when I try to build my solution I get 11 linker errors, all of them have the LNK2001 code except the last one, it has the LNK2019 code, I spent one hour and a half trying to fix it, but I just have no clue where the error is
I'm using Solokiller's SDK

Error List from VS2019:
Severity Code Description Project File Line Suppression State
Error LNK2001 unresolved external symbol "public: virtual int __thiscall CDeagle::AddToPlayer(class CBasePlayer *)" (?AddToPlayer@CDeagle@@UAEHPAVCBasePlayer@@@Z) hl_cdll E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\hl_weapons.obj 1
Error LNK2019 unresolved external symbol _EV_FireDeagle referenced in function "void __cdecl Game_HookEvents(void)" (?Game_HookEvents@@YAXXZ) hl_cdll E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\hl_events.obj 1
Error LNK2001 unresolved external symbol "public: virtual void __thiscall CDeagle::WeaponIdle(void)" (?WeaponIdle@CDeagle@@UAEXXZ) hl_cdll E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\hl_weapons.obj 1
Error LNK2001 unresolved external symbol "public: virtual void __thiscall CDeagle::Spawn(void)" (?Spawn@CDeagle@@UAEXXZ) hl_cdll E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\hl_weapons.obj 1
Error LNK2001 unresolved external symbol "public: virtual void __thiscall CDeagle::WeaponIdle(void)" (?WeaponIdle@CDeagle@@UAEXXZ) hl_cdll E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\hl_weapons.obj 1
Error LNK2019 unresolved external symbol _EV_FireDeagle referenced in function "void __cdecl Game_HookEvents(void)" (?Game_HookEvents@@YAXXZ) hl_cdll E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\hl_events.obj 1
Error LNK2001 unresolved external symbol "public: virtual int __thiscall CDeagle::Deploy(void)" (?Deploy@CDeagle@@UAEHXZ) hl_cdll E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\hl_weapons.obj 1
Error LNK2001 unresolved external symbol "public: virtual void __thiscall CDeagle::Holster(int)" (?Holster@CDeagle@@UAEXH@Z) hl_cdll E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\hl_weapons.obj 1
Error LNK2001 unresolved external symbol "public: virtual void __thiscall CDeagle::PrimaryAttack(void)" (?PrimaryAttack@CDeagle@@UAEXXZ) hl_cdll E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\hl_weapons.obj 1
Error LNK2001 unresolved external symbol "public: virtual void __thiscall CDeagle::SecondaryAttack(void)" (?SecondaryAttack@CDeagle@@UAEXXZ) hl_cdll E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\hl_weapons.obj 1
Error LNK2001 unresolved external symbol "public: virtual void __thiscall CDeagle::Reload(void)" (?Reload@CDeagle@@UAEXXZ) hl_cdll E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\hl_weapons.obj 1
Error LNK2001 unresolved external symbol "public: virtual void __thiscall CDeagle::Precache(void)" (?Precache@CDeagle@@UAEXXZ) hl_cdll E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\hl_weapons.obj 1
Error LNK2001 unresolved external symbol "public: virtual int __thiscall CDeagle::GetItemInfo(struct ItemInfo *)" (?GetItemInfo@CDeagle@@UAEHPAUItemInfo@@@Z) hl_cdll E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\hl_weapons.obj 1
Edit:

Output:

Build started...
1>------ Build started: Project: hl_cdll, Configuration: Debug Win32 ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(505,5): warning MSB8004: Output Directory does not end with a trailing slash. This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
1>hl_events.cpp
1> Creating library E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\Debug\hl_cdll\client.lib and object E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\Debug\hl_cdll\client.exp
1>hl_events.obj : error LNK2019: unresolved external symbol _EV_FireDeagle referenced in function "void __cdecl Game_HookEvents(void)" (?Game_HookEvents@@YAXXZ)
1>hl_weapons.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CDeagle::Spawn(void)" (?Spawn@CDeagle@@UAEXXZ)
1>hl_weapons.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CDeagle::Precache(void)" (?Precache@CDeagle@@UAEXXZ)
1>hl_weapons.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CDeagle::GetItemInfo(struct ItemInfo *)" (?GetItemInfo@CDeagle@@UAEHPAUItemInfo@@@Z)
1>hl_weapons.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CDeagle::AddToPlayer(class CBasePlayer *)" (?AddToPlayer@CDeagle@@UAEHPAVCBasePlayer@@@Z)
1>hl_weapons.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CDeagle::PrimaryAttack(void)" (?PrimaryAttack@CDeagle@@UAEXXZ)
1>hl_weapons.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CDeagle::SecondaryAttack(void)" (?SecondaryAttack@CDeagle@@UAEXXZ)
1>hl_weapons.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CDeagle::Deploy(void)" (?Deploy@CDeagle@@UAEHXZ)
1>hl_weapons.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CDeagle::Holster(int)" (?Holster@CDeagle@@UAEXH@Z)
1>hl_weapons.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CDeagle::Reload(void)" (?Reload@CDeagle@@UAEXXZ)
1>hl_weapons.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CDeagle::WeaponIdle(void)" (?WeaponIdle@CDeagle@@UAEXXZ)
1>E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\Debug\hl_cdll\client.dll : fatal error LNK1120: 11 unresolved externals
1>Done building project "hl_cdll.vcxproj" -- FAILED.
Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped
Posted 3 years ago2021-03-24 02:13:23 UTC Post #345475
We have a tutorial for a Desert Eagle weapon, try looking through it to see what you've missed.

"unresolved external symbol" linker errors are generally caused by a function being declared but not implemented. My guess is that you didn't add the deagle.cpp file (or whatever the file name actually is) to the client-side VS project. For new weapons, you need to include the file in both projects. (See the section in the tutorial under the heading "Basic class implementation" for details)
Penguinboy PenguinboyHaha, I died again!
Posted 3 years ago2021-03-24 03:02:28 UTC Post #345476
Thank you so much! you helped me fix 11 of the errors, the only one that's still there is the one with the LNK2019 code:
LNK2019 unresolved external symbol _EV_FireDeagle referenced in function "void __cdecl Game_HookEvents(void)" (?Game_HookEvents@@YAXXZ) hl_cdll E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\hl_events.obj 1

Output: Creating library E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\Debug\hl_cdll\client.lib and object E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\Debug\hl_cdll\client.exp
1>hl_events.obj : error LNK2019: unresolved external symbol _EV_FireDeagle referenced in function "void __cdecl Game_HookEvents(void)" (?Game_HookEvents@@YAXXZ)
1>E:\Modding HL1\HL1MK3.0\halflife-updated-master\projects\vs2019\Debug\hl_cdll\client.dll : fatal error LNK1120: 1 unresolved externals
Posted 3 years ago2021-03-24 03:37:19 UTC Post #345477
Also, could you link me to basic class implementation please
My internet is working so badly that I can't search anything, I already had this page loaded
Posted 3 years ago2021-03-24 13:11:25 UTC Post #345478
There is a link in the tutorial to the complete code, you can see it here: https://github.com/LogicAndTrick/halflife-updated/commit/tutorial-standard-weapons

For your last error, I think you are missing the EV_FireDesertEagle function in cl_dll/ev_hldm.cpp. The tutorial explains where changes need to be made, if you plan on adding any more weapons please read through it so you know which areas you need to update.
Penguinboy PenguinboyHaha, I died again!
You must be logged in to post a response.