Discussion Locked

Linker errors

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
A have made a program in c most of the line use # directives & also declare a extern variable & include this program in other program(2) but the compilation of program(2) gives the linker errors of not finding that globlly defined extern variable(which i have told u about).

1 reply

by marobertson

If I understand correctly, you have a program that consists of multiple modules, and want to have a global variable shared by all of them. To do that, you need to define the variable in one .cpp file like this;

double value;

and in all the other .cpp files like this:

extern double value;

The "extern" tells the compiler that the symbol will be available at link time from another module

Hope this helps

This discussion is closed to new replies.