Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Error LNK 2005 - fonction all ready define in a .obj  (Read 1352 times)

0 Members and 1 Guest are viewing this topic.

Cewein

  • Newbie
  • *
  • Posts: 1
    • View Profile
Error LNK 2005 - fonction all ready define in a .obj
« on: March 15, 2018, 12:34:28 pm »
Hello, I am develloping a application in cpp in VS2017.
there is no code error but there is compiling error.
I have used this tutorial for installing : https://www.kimsgamedev.com/setup-sfml-project-visual-studio-2017/

here a pastebin to the code :

case.h : https://pastebin.com/xCnpSVUR
main.cpp : https://pastebin.com/VHAG20YG

the error look like this :

Quote
1>case.obj : error LNK2005: "int __cdecl posCase(int * *,int,int,int)" (?posCase@@YAHPEAPEAHHHH@Z)  already define in case.obj
1>case.obj : error LNK2005: "int __cdecl ramCase(int * *,int)" (?ramCase@@YAHPEAPEAHH@Z) already define in case.obj
1>case.obj : error LNK2005: "int __cdecl numberCase(void)" (?numberCase@@YAHXZ) already define in case.obj
1>Main.obj : error LNK2005: "void __cdecl clickMouse(int * *,int,class sf::RenderWindow &)" (?clickMouse@@YAXPEAPEAHHAEAVRenderWindow@sf@@@Z) already define in Main.obj

may i have include headers in a wrong way ?

thanks in advence, and sorry for languages error or the french in pastebin

- Cewein

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Error LNK 2005 - fonction all ready define in a .obj
« Reply #1 on: March 15, 2018, 12:39:03 pm »
Functions implemented in header files should be inline, otherwise they end up being defined in every .cpp that include the header, and the linker doesn't like duplicated definitions.

Note that this has absolutely nothing to do with SFML, it's basic C++ knownledge.
Laurent Gomila - SFML developer