Reputation: 4218
I have defined a global variable in a c++ file. eg: bool _variable =1;
Now i use this variable in other c++ file using : extern bool _variable
.
But i am getting the error error LNK2001: unresolved external symbol
"bool _variable" (?_variable@@3_NA)
.
How can i resolve this error??
Upvotes: 0
Views: 719
Reputation: 1797
Maybe you forgot to include file with defined variable into the project (assuming you're using VS).
Upvotes: 1
Reputation: 26060
It means the linker cannot find the definition of such variable.
Are you sure you wrote it in the same way anywhere?
Are you sure the c++ file containing the definition gets compiled and linked with the others when you're getting such error?
Are you sure the namespace where such variable is defined is the same?
Upvotes: 4