Using the Turbo C++ Project facility, I have linked some 5-6 files
which consist of function definitions with a file which contains the
definition of main(). main() uses the function definitions that are given
in the other files. There are a lot of variables which need to be
accessed by all the functions. So I have declared them to be global.

The file that contains the main() definition compiles successfully but on
linking it gives the error :

Linker Error :
Undefined symbol 'function_name' in module 'file_containing_main'.

On compiling the files that contain other function definitions, it gives an
error :

Error :
Undefined symbol 'global_variable'.

I had done the same thing with another project which did not involve
global variables & it had worked.

So what should I do now ?

Re: Plz help : Multifile C programs (details included) 80 80

Hmm, what I think you need to do is declare your functions and variables in another header file that uses the extern keyword in front of them (this means that the function has already been declared). #include this file with all source files that need it. (And you may want to make sure that your global variables are defined in a .cpp file, and not a header file.)

As for undefined functions, have you got all your functions coded and included in your project? The reason these errors occur is when the linker can find where the functions are declared, but can't find where the they are actually defined. So check your code modules carefully!

Hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.