CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Dec 2007
    Location
    France
    Posts
    329

    Already defined function error LNK2005

    I created a very simple c++ win32 project in MSVC 2010.

    I added a .cpp file with the function definition and a .h file with the function prototype and I get this "function already defined" error.

    I included both .h and .cpp file to the corresponding stdafx.h and stdafx.cpp files.
    I really dont see what can be the problem. I did exactly as on the video tutorial where it was working.

    Player.cpp
    Code:
    #include "stdafx.h"
    
    void f()
    {
        MessageBox(0,0,0,0);
    }
    Player.h
    Code:
    void f();
    1>stdafx.obj : error LNK2005: "void __cdecl f(void)" (?f@@YAXXZ) already defined in Player.obj
    1>D:\DIRECTSHOW\MediaPlayer\Debug\MediaPlayer.exe : fatal error LNK1169: one or more multiply defined symbols found
    Last edited by MasterDucky; July 9th, 2014 at 06:11 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured