1. 程式人生 > >fatal error LNK1169: 找到一個或多個多重定義的符號

fatal error LNK1169: 找到一個或多個多重定義的符號

編譯 gpo .cpp post 多重 print use 控制 包含

在vs中,使用c時,由編譯-鏈接,cpp之間是自動的,如:

1,頭文件 x.h:

1  int f();

2,實現 impl.cpp:

1 #include "stdafx.h"
2 
3 int f() {
4     return 1;
5 }

3,在main(即user_extern.cpp)中(使用實現 impl.cpp不需要include impl.cpp),只要include 包含 int f();的 頭文件(即 x.h)

 1 // user_extern.cpp : 定義控制臺應用程序的入口點。
 2 //
 3 
 4 #include "stdafx.h"
 5 #include "
x.h" 6 7 8 int _tmain(int argc, _TCHAR* argv[]) 9 { 10 int i= f(); 11 printf("%d",i); 12 return 0; 13 }

fatal error LNK1169: 找到一個或多個多重定義的符號