Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3021

Already defined function error LNK2005

$
0
0
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();
Quote:

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

Viewing all articles
Browse latest Browse all 3021

Trending Articles