LinuxQuestions.org
Help answer threads with 0 replies.
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-19-2011, 12:09 AM   #1
shamjs
Member
 
Registered: Sep 2011
Posts: 93

Rep: Reputation: Disabled
soname creation


Hi all,
i need to create shared library for my project

these is my directory structure.
home/shamjs/source->mainpgm
home/shamjs/source/inc->pgm1.h,pgm2.h,pgm3.h,pgm4.h,pgm5.h,....8.h
home/shamjs/source/src->
pgm1.cpp,pgm2.cpp,pgm3.cpp,pgm4.cpp,pgm5.cpp,....8.cpp

im following this steps to create .so file

1>make

2>ld -shared -soname MyLib.so.1 -o MyLib.so.1.0 -lc pgm1.o pgm2.o pgm3.o pgm4.o gpm5.o pgm6.o pgm7.o pgm8.o

after executing this step real name will be created MyLib.so.1.0

3>export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH

4>/sbin/ldconfig -v -n .

after executing this i get
.:

but i wont get MyLib.so.1 -> MyLib.so.1.0.1 (changed)
the above output and no soname will be created....

5>ln -sf MyLib.so.1 MyLib.so

after executing this i get MyLib.so(linker name gets created)


my problem is, since the soname is not being created (MyLib.so.1) hence, im unable to execute my program ,by only using MyLib.so.1.o or MyLib.so files

please suggest me what can be done........

waiting for your reply........
 
Old 12-19-2011, 02:53 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,864
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
That's what libtool is good for. It's something like this:

Code:
mkdir ~/lib

libtool --mode=compile g++ -o pgm1.lo -c pgm1.cc
...
libtool --mode=compile g++ -o pgm8.lo -c pgm8.cc

libtool --mode=link g++ -o libmylib.la -rpath ~/lib -version-info 1:0:0 pgm*.o
libtool --mode=install cp libmylib.la ~/lib
 
Old 12-19-2011, 03:42 AM   #3
shamjs
Member
 
Registered: Sep 2011
Posts: 93

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by NevemTeve View Post
libtool --mode=link g++ -o libmylib.la -rpath ~/lib -version-info 1:0:0 pgm*.o
libtool --mode=install cp libmylib.la ~/lib
[/code]
but i need to create a dynamic library instead of static one..........

plz suggest me for this...........
 
Old 12-19-2011, 04:35 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,864
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
> but i need to create a dynamic library instead of static one..........

Relax, libtool does generate both. (Unless you omit the "-rapth ~/lib" part).

PS: Well, here is a correction:

Code:
libtool --mode=link g++ -o libmylib.la -rpath ~/lib -version-info 1:0:0 pgm*.lo
 
1 members found this post helpful.
Old 12-20-2011, 06:24 AM   #5
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
Besides NevemTeve way: I think in the origin there was one entry too much: you had MyLib.so.1, MyLib.so.1.0 and were looking for MyLib.so.1.0.1 and MyLib.so . Usually there are only three like:

MyLib.so -> MyLib.so.1.0
MyLib.so.1.0 -> MyLib.so.1.0.1
MyLib.so.1.0.1

with -soname MyLib.so.1.0 and output MyLib.so.1.0.1 , it should work to create the missing links by hand (no ldconfig at all). There is a document from IBM.
 
  


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
[SOLVED] Prevent subdirectory creation while allowing file creation bweddell Linux - Security 5 07-31-2011 08:54 PM
System user creation with mysql user creation moos3 Programming 1 08-11-2007 08:01 PM
Gui creation PatrickNew Programming 7 10-13-2006 11:54 AM
same soname but different type acidjuice Slackware 11 05-12-2005 03:41 AM
How to link to soname? ugenn Linux - Software 4 01-23-2003 06:26 AM

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

All times are GMT -5. The time now is 12:20 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