Unresolved external symbol help

My code is set up like this
facilities.h which is pre-written
the error is:
1>my.obj : error LNK2001: unresolved external symbol "int foo" (?foo@@3HA)
1>c:\users\mattdesktop\documents\visual studio 2010\hw\chp8drill\Debug\chp8drill.exe : fatal error LNK1120: 1 unresolved externals

my.h
1
2
3
extern int foo;
void print_foo();
void print(int);


my.cpp
1
2
3
4
5
6
7
8
9
#include "my.h"
#include "C:\Users\MattDesktop\Desktop\std_lib_facilities.h"

void print_foo(){
	cout<<foo<<endl;
}
void print(int i){
	cout<<i<<endl;
}


use.cpp
1
2
3
4
5
6
7
8
9
10
11
12
#include "my.h"
#include "C:\Users\MattDesktop\Desktop\std_lib_facilities.h"

int main(){
	int foo=7;
	print_foo;
	print(99);
	
	char cc;
	cin>>cc;

}


Can't figure out how to fix this error, any ideas?
In my.h, you claim there is an external global integer called foo, but I don't see such a thing defined anywhere. Note that the foo in use.cpp is local and not a candidate for that reference.
Oh I see, I thought using extern meant that foo would be shared everywhere in my main function.

I changed the code to the following and it worked perfect. Thanks!
use.cpp
1
2
3
4
5
6
7
8
9
int foo=7;
int main(){
	print_foo();
	print(99);javascript:editbox1.editSend()
	
	char cc;
	cin>>cc;

}
Topic archived. No new replies allowed.