The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
merge files koti_rama Shell Programming and Scripting 5 12-24-2007 06:59 PM
How to merge files lestat_ecuador Shell Programming and Scripting 3 06-07-2007 03:45 AM
merge multiple lines from flat file hnhegde Shell Programming and Scripting 4 12-05-2006 03:13 PM
Use sed to merge multiple lines xb88 Shell Programming and Scripting 3 08-08-2006 10:54 AM
help in merge files u263066 Shell Programming and Scripting 5 07-24-2006 12:24 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-15-2006
Registered User
 

Join Date: Feb 2006
Posts: 2
Stumble this Post!
How to Merge or Link 2 independent .so files

Hi all,

I am developing an application in Tcl, inwhich i have to load many modules written in C. I am converting those C modules into shared object(.so) files, and wrap it with my application using SWIG, for which i had the interface file.

Now my question is, i have two different .so files, let me name it as (prog1.so) and (prog2.so). My prog1.so contains 5 functions and my prog2.so contains 3 functions.

If i load prog1.so file individually in tclsh shell, i can able to call the functions available in prog1.so. Similarly for prog2.so also. But i want to call all the functions available in both the prog1.so and prog2.so .

Can Anyone help me to sort this problem out !!!!!!!!!!!!!!!!!!!!!!!!!!!

Here is the procedure what i did. kindly correct me if i did something wrong.

step 1:
------
I have the "prog1.c" file and interface file "prog1.i " and creating a wrapper code for it using the command

$ swig -tcl prog1.i

This will give me "prog1_wrap.c" which is a wrapper code for my C program.

step 2:
------
Now i compile the prog1.c and prog1_wrap.c using the following command

$ gcc -fPIC -c prog1.c prog1_wrap.c -I /usr/local/include

This will give me prog1.o and prog1_wrap.o files.


step 3:
------
Now i create a prog1.so file using the following command

$ gcc -shared prog1.o prog1_wrap.o -o prog1.so

step 4:
------

Here i will go to the tclsh shell and Load the (.so) file.

% load ./prog1.so prog1

This will load the file and i can able to call the function available in prog1.c

++++++++++++++++++++++++++++++++++++++++++++++++++++++

I can do the same for any no.of programs individually. But if i try to combine shared object files of two programs i can't able to load it in tclsh shell.

I tried with the following commands to merge the (.so) files, I doesnt know whether it make sense.

1.
$ gcc -shared prog1.so prog2.so -o combine.so

2.
$ gcc -shared prog1.o prog1_wrap.o prog2.o prog2_wrap.o -o combine.so


I hope these where not correct method to merge a two different shared object file.

I am Expecting your Valuable suggestions!!!
Thanks in Advance.



Regards,
Kumar.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-04-2008
Registered User
 

Join Date: Jul 2008
Posts: 1
Stumble this Post!
Merge multiple .so files

Hi,

I saw your post on unix.com about linking multiple .so files

http://www.unix.com/unix-advanced-ex...-so-files.html

and I was wondering if you found a solution to your problem?

Please let me know.

Thanks!
Teena
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:02 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0