LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-21-2009, 06:00 PM   #1
morty346
Member
 
Registered: Feb 2009
Posts: 52

Rep: Reputation: 15
Multiple Shared Object Instances in one C++ app Shares data references???


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
 
Old 12-21-2009, 11:14 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
No - *nix shared libraries are *not* Windows .dll's.
 
Old 12-22-2009, 06:40 AM   #3
morty346
Member
 
Registered: Feb 2009
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by paulsm4 View Post
No - *nix shared libraries are *not* Windows .dll's.
ok.... so ???
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
DFS shares - can mount shared folder, but no access - error "object is remote" gbloon Linux - Networking 6 08-20-2009 05:18 PM
./app: error while loading shared libraries: libfg.so: cannot open shared object file x_gaurav Linux - Newbie 2 06-27-2009 12:32 PM
Question about C++ and member functions thar return constant object references sonajiso Programming 2 01-28-2008 11:23 AM
error while loading shared libraries: libgvc.so.3: cannot open shared object file coolrock Slackware 6 01-17-2007 05:10 PM
error while loading shared libraries: libdb-4.1.so: cannot open shared object file putquery8581 Linux - Software 1 10-01-2004 07:03 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration