Link error in Solaris
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Link error in Solaris




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Link error in Solaris  
googler


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-23-06 06:17 AM

I have a Makefile that I use to compile in Linux. Using the same
Makefile to compile the same code in Solaris 10 gives me error in the
link stage.

g++ -shared -Wl,-soname,libstorelib.so.1 -o  libstorelib.so.2.5-1
slcommon.o sldebug.o slaenregister.o slaenprocessor.o sltopology.o
slsolaris.o -L/usr/lib -lpthread -ldl
ld: warning: option -o appears more than once, first setting taken
ld: fatal: file libstorelib.so.1: open failed: No such file or
directory
ld: fatal: File processing errors. No output written to
libstorelib.so.2.5-1
collect2: ld returned 1 exit status
*** Error code 1
dmake: Fatal error: Command failed for target `libstorelib.so.2.5-1'

How shall I modify the Makefile to compile in Solaris? From 'man ld' I
saw that -soname option is not present. I am using g++ version 3.4.3.

I am pasting the relevant part from my Makefile below.

....
....
LIB_NAME = libstorelib.so.$(LIB_VER)-$(LIB_VER_QUALIFIER)
OBJS=slcommon.o sldebug.o slaenregister.o slaenprocessor.o sltopology.o
slsolaris.o
LIBS=-L/usr/lib -lpthread -ldl

all: storelib
storelib: /usr/lib/libstorelib.so
/usr/lib/libstorelib.so: $(LIB_NAME)
rm -f /usr/lib/libstorelib.so*
cp  $(LIB_NAME) /usr/lib/
ldconfig
ln -sf /usr/lib/libstorelib.so.1 /usr/lib/libstorelib.so
$(LIB_NAME): $(OBJS)
g++ -shared -Wl,-soname,libstorelib.so.1 -o  $(LIB_NAME) $(OBJS)
$(LIBS)
....
....

I understand that the ldconfig needs to be replaced by crle, but for
now the error occurs even before that.

Any help will be greatly appreciated. Some pointer to sample Makefile
(in Solaris) might be of help too.






[ Post a follow-up to this message ]



    Re: Link error in Solaris  
Paul Pluzhnikov


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-23-06 06:17 AM

"googler" <pinaki_m77@yahoo.com> writes:

> I have a Makefile that I use to compile in Linux. Using the same
> Makefile to compile the same code in Solaris 10 gives me error in the
> link stage.

As it should. You are passing GNU-ld specific option (-soname)
to solaris ld, which treats it as if '-s -oname libstorelib.so.1'

> How shall I modify the Makefile to compile in Solaris? From 'man ld' I
> saw that -soname option is not present.

Use appropriate solaris ld switch (-h).

> I am using g++ version 3.4.3.

That's irrelevant.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.





[ Post a follow-up to this message ]



    Re: Link error in Solaris  
Casper H.S. Dik


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-23-06 12:16 PM

"googler" <pinaki_m77@yahoo.com> writes:

>g++ -shared -Wl,-soname,libstorelib.so.1 -o  libstorelib.so.2.5-1
>slcommon.o sldebug.o slaenregister.o slaenprocessor.o sltopology.o
>slsolaris.o -L/usr/lib -lpthread -ldl
>ld: warning: option -o appears more than once, first setting taken
>ld: fatal: file libstorelib.so.1: open failed: No such file or
>directory
>ld: fatal: File processing errors. No output written to
>libstorelib.so.2.5-1
>collect2: ld returned 1 exit status
>*** Error code 1
>dmake: Fatal error: Command failed for target `libstorelib.so.2.5-1'

>How shall I modify the Makefile to compile in Solaris? From 'man ld' I
>saw that -soname option is not present. I am using g++ version 3.4.3.


The -Wl,-soname,libstorelib.so.1 option is parsed by the Solaris linker
as:
-s -o name libstorelib.so.1

hence the complaint about -o appearing more than once and libstorelib.so.1
being a file not found.

You want to use:

-Wl,-h,libstorelib.so.1

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.





[ Post a follow-up to this message ]



    Re: Link error in Solaris  
googler


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-24-06 06:20 AM

Casper H.S. Dik wrote:
> "googler" <pinaki_m77@yahoo.com> writes:
> 
> 
>
>
> The -Wl,-soname,libstorelib.so.1 option is parsed by the Solaris linker
> as:
> 	-s -o name libstorelib.so.1
>
> hence the complaint about -o appearing more than once and libstorelib.so.1
> being a file not found.
>
> You want to use:
>
> 	-Wl,-h,libstorelib.so.1
>
> Casper

Thanks. The -h option worked fine. A couple of related questions on the
same Makefile. This is what it looks like.

all: storelib
storelib: /usr/lib/libstorelib.so
/usr/lib/libstorelib.so: $(LIB_NAME)
rm -f /usr/lib/libstorelib.so*
cp  $(LIB_NAME) /usr/lib/
ldconfig
ln -sf /usr/lib/libstorelib.so.1 /usr/lib/libstorelib.so
$(LIB_NAME): $(OBJS)
g++ -shared -Wl,-soname,libstorelib.so.1 -o  $(LIB_NAME)
$(OBJS) $(LIBS)

Since I cannot use ldconfig in Solaris, I am trying to use crle
instead. ldconfig when executed will create a link called
libstorelib.so.1 (which is the soname) for $(LIB_NAME) and will also
update the directory cache. I am wondering if crle can do the same
thing. From what I read on manpage, it appears that it won't create any
link for soname. Then shall I use the ln command myself to create this
link?

Here is what it looks like after my changes.
/usr/lib/libstorelib.so: $(LIB_NAME)
rm -f /usr/lib/libstorelib.so*
cp  $(LIB_NAME) /usr/lib/
ln -sf  /usr/lib/$(LIB_NAME)  /usr/lib/libstorelib.so.1  #added
crle -u   #added
ln -sf /usr/lib/libstorelib.so.1 /usr/lib/libstorelib.so

Is this OK? Will the -u option with crle update the directory cache
too?

Also, on trying to play with crle command, I saw that this command
"crle -i /lib -i /usr/lib" (for adding entries from the specified
directories into the directory cache) adds entries from the directories
/usr/openwin/lib and /usr/dt/lib too to the cache, as evident from a
subsequent "crle" command. I didn't understand why this should happen.






[ Post a follow-up to this message ]



    Re: Link error in Solaris  
Casper H.S. Dik


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-24-06 12:16 PM

"googler" <pinaki_m77@yahoo.com> writes:


>Thanks. The -h option worked fine. A couple of related questions on the
>same Makefile. This is what it looks like.

>all: storelib
>storelib: /usr/lib/libstorelib.so
>/usr/lib/libstorelib.so: $(LIB_NAME)
>        rm -f /usr/lib/libstorelib.so*
>        cp  $(LIB_NAME) /usr/lib/
>        ldconfig
>        ln -sf /usr/lib/libstorelib.so.1 /usr/lib/libstorelib.so
>$(LIB_NAME): $(OBJS)
>        g++ -shared -Wl,-soname,libstorelib.so.1 -o  $(LIB_NAME)
>$(OBJS) $(LIBS)

I would suggest that you also add a "chmod" in there somewhere and link
before you start installing.  (Otherwise the lib is gone if the
link fails)

I'm somewhat surprised at both the copy and the "g++ -o $(LIB_NAME)"

>Since I cannot use ldconfig in Solaris, I am trying to use crle
>instead. ldconfig when executed will create a link called
>libstorelib.so.1 (which is the soname) for $(LIB_NAME) and will also
>update the directory cache. I am wondering if crle can do the same
>thing. From what I read on manpage, it appears that it won't create any
>link for soname. Then shall I use the ln command myself to create this
>link?

If you install a library in /usr/lib, then there's nothing else you
need to do.  It will be found.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:38 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register