0
我有這個簡單的例子,我無法得到它來編譯:LNK2001錯誤使用的extern INT
三個文件:my.h,my.cpp和use.cpp:
//my.h
extern int foo;
void print_foo();
void print(int);
//my.cpp
#include "my.h"
#include "../../stb_lib_facilities.h" //inlcudes cout, cin, etc
void print_foo(){
cout << foo << endl;
}
void print(int i){
cout << i << endl;
}
//use.cpp
#include <iostream>
#include "my.h"
int main(){
foo = 7;
print_foo();
print(99);
return 0;
}
當我嘗試編譯它,我得到三個錯誤: LNK2001:外部的 「INT富」 .. LNK2019:外部的 「INT富」 .. LNK1120:
我在做什麼錯? 感謝您的任何幫助
謝謝!足夠清晰 – 2013-03-09 22:24:00
@nachogsiri:很高興能幫到你 – 2013-03-09 22:26:58