Global variables and shared objects...
Jupp Tscheak
jupp_tscheak@gmx.de
Thu Feb 24 11:50:00 GMT 2005
Hi,
Don't know if this is the right list but I think that's
somehow a compiler issue. However, I try to make a global
variable visible in a shared object in this way:
in globalHeader.hh:
class Module;
extern Module *pModule;
...
EOF
in Main.cc:
#include "Module.hh"
Module *pModule;
int main(..)
{
...
pModule = new Module( ... );
Executor exec = new Execoter( pModule );
...
}
EOF
in functions.c:
#include "globalHeader.hh"
#include "Module.hh"
...
void foo()
{
pModule->getSomething();
}
many C-functions
...
EOF
The executable "Module" is build from Main.o and Module.o.
A shared object is build from functions.o and other objects.
The shared object is also used by other modules that are in
process space of Executer. If I want to compile another module
that uses this shared objects, the compiler says
undefined reference to pModule->getSomething.
This error is obvious because I do not bind Module.o and Main.o
into the shared object. But if I do so how should another module
know where in ram is pModule.
I hope you could get the idea also it's a bit curios explained!
Any ideas??
Thanks in advance
Jupp Tscheak
More information about the Gcc-help
mailing list