Solved

Dynamic Link Libraries

Posted on 1998-07-17
3
183 Views
Last Modified: 2010-04-21
Hi,
Could somebody pls tell me how to build a .so file in UNIX ?.
0
Comment
Question by:lvenkat
3 Comments
 
LVL 2

Expert Comment

by:mlev
ID: 2008887
Which UNIX? It's different on nearly all of them.
There's a GNU tool called "libtool" that tries to standardise
that process (it knows how to build shared libraries for
various platforms); you might want to use it if you need
to create a portable package. Otherwise, if you only need
it for a specific platform, tell me which one and I'll tell you
the necessary compiler/linker flags.
0
 
LVL 1

Accepted Solution

by:
Rajkumar_R earned 200 total points
ID: 2008888
Say you have two files file1.cpp and file2.cpp out of which you have to make a so file with the name myso.so.

step:1

Build all the .cpp or .c etc files with -kpic option. (just make the .o files)

$ CC -Kpic -c file1.cpp file2.cpp

step:2

Make the .so as follows

$CC -G -o myso.so  file1.o  file2.o

you will get the shared object: myso.so



0
 
LVL 3

Expert Comment

by:braveheart
ID: 2008889
It *is* slightly different on all flavours of UNIX but the only difference is the option on the linker command. To determine which option you should use on each platform you will have to RTFM.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question