I created a SO that I want to use multiple instances of in one application (it is a manager for sending/receiving commands from an rs232 line And I want to echo commands on multiple devices(its complicated, please don't challenge my methods for doing it, I am right)
Code:
void *Handle = dlopen("libTActionReader.so", RTLD_NOW);
void *Handle2 = dlopen("libTActionReader2.so", RTLD_NOW);
I have an init function that switches a bool on if it has been initialized before
When I call it using Handle2 func ptr, I am given an error code stating it has already been initialzed
Code:
typedef int (*InitializeTactionReader_t)(bool threaded);
InitializeTactionReader_t InitializeTActionReader = (InitializeTactionReader_t) dlsym(Handle, "InitializeTActionReader");
InitializeTactionReader_t InitializeTActionReader2 = (InitializeTactionReader_t) dlsym(Handle2, "InitializeTActionReader");
printf("Handle 1 %d\n", Handle);
printf("Handle 2 %d\n", Handle2);//they print out different address
From what I understand of DLLs and SO, is that the programs will share the memory for the functions, but will have their own instances of the data inside the dll, is this not true?
(in the case from above, I have named the so differently, so shouldn't they ALSO be NOT sharing memory for the functions?
The variable is a global bool
Sidenote: - Would it matter if it is a static variable?
I using CentOS 5.4 for my OS, I am developing in C++ using Code::Blocks my glibc version is 2.5.4
I am a Windows programmer, and fairly new to this OS, please be kind
Thank you For you help