The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

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 10:59 PM
How to merge files lestat_ecuador Shell Programming and Scripting 3 06-07-2007 06:45 AM
merge multiple lines from flat file hnhegde Shell Programming and Scripting 4 12-05-2006 07:13 PM
Use sed to merge multiple lines xb88 Shell Programming and Scripting 3 08-08-2006 01:54 PM
help in merge files u263066 Shell Programming and Scripting 5 07-24-2006 03:24 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-15-2006
senthilvnr senthilvnr is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 2
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.
  #2 (permalink)  
Old 07-04-2008
dulcet dulcet is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 1
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
  #3 (permalink)  
Old 01-27-2009
void_void void_void is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 1
!

hello friend,

will you please tell me how can i use ".so file" into my c code

i've wrrten a function

void print(){
printf("Hello world");
}

now i have created its ".so" now how can i use this function(print()) into my c code directly i mean how can i link these . . .
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0