Linking error when trying to build project (LNK2005 & NMAKE : fatal error U1077)

-1
LINK Pass 1: command "C:\PROGRA~2\MICROS~2\2017\COMMUN~1\VC\Tools\MSVC\1415~1.267\bin\Hostx86\x86\link.exe /nologo @CMakeFiles\Risk.dir\objects1.rsp /out:Risk.exe /implib:Risk.lib /pdb:C:\Users\aloys\Documents\GitHub\Risk\cmake-build-debug\Risk.pdb /version:0.0 /machine:X86 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\Risk.dir/intermediate.manifest CMakeFiles\Risk.dir/manifest.res" failed (exit code 1120) with the following output:
AttackingPhase.cpp.obj : error LNK2005: "int numberOfArmiesAttacker" (?numberOfArmiesAttacker@@3HA) already defined in Main.cpp.obj
AttackingPhase.cpp.obj : error LNK2005: "int numberOfArmiesDefender" (?numberOfArmiesDefender@@3HA) already defined in Main.cpp.obj
AttackingPhase.cpp.obj : error LNK2005: "class Player Attacker" (?Attacker@@3VPlayer@@A) already defined in Main.cpp.obj
AttackingPhase.cpp.obj : error LNK2005: "class std::vector<class Player,class std::allocator<class Player> > PlayerVec" (?PlayerVec@@3V?$vector@VPlayer@@V?$allocator@VPlayer@@@std@@@std@@A) already defined in Main.cpp.obj
AttackingPhase.cpp.obj : error LNK2005: "class Player Defender" (?Defender@@3VPlayer@@A) already defined in Main.cpp.obj
AttackingPhase.cpp.obj : error LNK2005: "class Territory AttackCountry" (?AttackCountry@@3VTerritory@@A) already defined in Main.cpp.obj
AttackingPhase.cpp.obj : error LNK2005: "class Territory DefendCountry" (?DefendCountry@@3VTerritory@@A) already defined in Main.cpp.obj
Main.cpp.obj : error LNK2019: unresolved external symbol "public: void __thiscall Territory::setArmies(int)" (?setArmies@Territory@@QAEXH@Z) referenced in function _main
AttackingPhase.cpp.obj : error LNK2001: unresolved external symbol "public: void __thiscall Territory::setArmies(int)" (?setArmies@Territory@@QAEXH@Z)
Risk.exe : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files\JetBrains\CLion 2018.2.5\bin\cmake\win\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.

I have no errors when I reload the CMake Project. I've checked the CMakeList to make sure that all cpp and h files are included. This file is only functions, there is no class. It is called "AttackingPhase.cpp" has a corresponding header file with all prototypes and global variables declared. Tried on my computer on windows and ubuntu, tried on another person's computer. Tried multiple IDEs. Any ideas?

c++
clion
asked on Stack Overflow Nov 5, 2018 by A. Port • edited Nov 5, 2018 by drescherjm

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0