Merge multiple .so files


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Merge multiple .so files
# 1  
Old 02-15-2006
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  
Old 07-04-2008
Merge multiple .so files

Hi,

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

https://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  
Old 01-27-2009
!

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 . . .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Merge Multiple html files into one

Hi all I have written some code to write my output in html. As i have multiple servers, need to generate single html file. but my code is generating html file for each server. I have merged the files using below code. cat /home/*_FinalData.html > /home/MergedFinalData.html But how to... (1 Reply)
Discussion started by: Snehasish
1 Replies

2. Shell Programming and Scripting

Merge multiple files with common header

Hi all, Say i have multiple files x1 x2 x3 x4, all with common header (date, time, year, age),, How can I merge them to one singe file "X" in shell scripting Thanks for your suggestions. (2 Replies)
Discussion started by: msarguru
2 Replies

3. Shell Programming and Scripting

How to merge the multiple data files as a single file?

Hi Experts, I have created multiple scripts and send the output to new file, getting this output to my mailbox on daily basis. I would like to send the all outputs to a single file, need to merge all file outputs on a single file. For example, Created script for df -h > df.doc grep... (7 Replies)
Discussion started by: seenuvasan1985
7 Replies

4. Shell Programming and Scripting

Merge columns from multiple files

Hello and Good day I have a lot of files with same number of rows and columns.$2 and $3 are the same in all files . I need to merge $2,$3,$6 from first file and $6 from another files. File1: $1 $2 $3 $4 $5 $6... (8 Replies)
Discussion started by: ali.seifaddini
8 Replies

5. Shell Programming and Scripting

Merge the multiple text files into one file

Hi All, I am trying to merge all the text files into one file using below snippet cat /home/Temp/Test/Log/*.txt >> all.txt But it seems it is not working. I have multiple files like Output_ServerName1.txt, Output_ServreName2.txt I want to merge each file into one single file and... (6 Replies)
Discussion started by: sharsour
6 Replies

6. UNIX for Dummies Questions & Answers

Merge columns from multiple files

Hi all, I've searched the web for a long time trying to figure out how to merge columns from multiple files. I know paste will append columns like so: paste file1 file2 file3 file4 file5 ... But this becomes inconvenient when you want to append a large number of files into a single file. ... (2 Replies)
Discussion started by: torchij
2 Replies

7. UNIX for Dummies Questions & Answers

Merge multiple files

Hi All, How can I merge 3rd column of multiple files into 1 file, the column header in the merged file being the name of the file from which the 3rd column was taken. The first 2 columns of all the files are exactly same. Thanks for your help ! (3 Replies)
Discussion started by: newbie83
3 Replies

8. UNIX for Advanced & Expert Users

merge two column multiple files into one

Hi I have multiple files each with two columns and I need to combine all those file into a tab delimited file. (multiple entry with same name separated by a comma) The content of the files are as follows: --- file1.txt: name var1 aaa xx aaa gg bbb yy ddd zz --- file2.txt ... (8 Replies)
Discussion started by: mary271
8 Replies

9. Shell Programming and Scripting

Merge Multiple Files and Transpose

Looking to join three files and then transpose some columns from multiple rows into a single row. File Info: FIELD TERMINATED BY '^' ENCLOSED BY '~' LINE TERMINATED BY '\r\n' FIRST FILE (FOOD_DES.txt) ~01001~^~0100~^~Butter, salted~^~BUTTER,WITH... (2 Replies)
Discussion started by: mkastin
2 Replies

10. Shell Programming and Scripting

Help to merge multiple .sql files

Hello all, I have a shell script that uses multiple .sql files. These .sql files mainly contain Oracle SQL queries to pull fields from the database. I want to place all the contents of these .sql files in one .sql file and have some parameter sent based on which the respective block or query... (6 Replies)
Discussion started by: snvniranjanrao
6 Replies
Login or Register to Ask a Question