public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Statically linked shared library
@ 2009-03-12 15:39 Kolesar
  2009-03-13 17:21 ` Axel Freyn
  2009-03-14 20:49 ` Michael Haubenwallner
  0 siblings, 2 replies; 10+ messages in thread
From: Kolesar @ 2009-03-12 15:39 UTC (permalink / raw)
  To: gcc-help


Hi All

I try linked shared library, statically, but i get error. Where I made
mistake? Please help.

Exactly, I want dynamically linked -ldl -lrt -luuid -lm -ldl, and statically
linked -ldrmod (libdrmod.so)


g++ -static -ldl -lrt -luuid -lm -ldl -o
/home/asimh/my_program/src/.bin/sysnfop1s.so
-L/home/asimh/my_program/lib/.bin -ldrmod

/usr/bin/ld: cannot find -ldrmod





-- 
View this message in context: http://www.nabble.com/Statically-linked-shared-library-tp22478672p22478672.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Statically linked shared library
  2009-03-12 15:39 Statically linked shared library Kolesar
@ 2009-03-13 17:21 ` Axel Freyn
  2009-03-14 20:49 ` Michael Haubenwallner
  1 sibling, 0 replies; 10+ messages in thread
From: Axel Freyn @ 2009-03-13 17:21 UTC (permalink / raw)
  To: gcc-help

Hi,
On Thu, Mar 12, 2009 at 08:39:34AM -0700, Kolesar wrote:
> I try linked shared library, statically, but i get error. Where I made
> mistake? Please help.
> 
> Exactly, I want dynamically linked -ldl -lrt -luuid -lm -ldl, and statically
> linked -ldrmod (libdrmod.so)
> 
> 
> g++ -static -ldl -lrt -luuid -lm -ldl -o
> /home/asimh/my_program/src/.bin/sysnfop1s.so
> -L/home/asimh/my_program/lib/.bin -ldrmod
> 
> /usr/bin/ld: cannot find -ldrmod

g++ treats the last parameter as a filename to work on. You passed as
last parameter "-ldrmod", so g++ believes that's a file in the actual
direcory. As this filename as no extension (like .c, .cc,...), g++ does
not try to compile it but passes the filename to the linker ld - which
creates the error message "cannot find -ldrmod": it does not find a file
named "-ldrmod" in the current working directory...

Axel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Statically linked shared library
  2009-03-12 15:39 Statically linked shared library Kolesar
  2009-03-13 17:21 ` Axel Freyn
@ 2009-03-14 20:49 ` Michael Haubenwallner
  2009-03-16 14:35   ` Kolesar
  1 sibling, 1 reply; 10+ messages in thread
From: Michael Haubenwallner @ 2009-03-14 20:49 UTC (permalink / raw)
  To: Kolesar; +Cc: gcc-help

On Thu, 2009-03-12 at 08:39 -0700, Kolesar wrote:
> Hi All
> 
> I try linked shared library, statically, but i get error. Where I made
> mistake? Please help.
> 
> Exactly, I want dynamically linked -ldl -lrt -luuid -lm -ldl, and statically
> linked -ldrmod (libdrmod.so)

As far as I can tell, statically linking a shared library does not work
for example on Linux, Solaris, HP-UX, Windows.
The only platform I know of being able to do that is AIX.

> g++ -static -ldl -lrt -luuid -lm -ldl -o
> /home/asimh/my_program/src/.bin/sysnfop1s.so
> -L/home/asimh/my_program/lib/.bin -ldrmod
> 
> /usr/bin/ld: cannot find -ldrmod

When switched to static linking, the linker does not search for your
libdrmod.so, but libdrmod.a only (even on AIX), which simply does not
exist.

HTH,
/haubi/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Statically linked shared library
  2009-03-14 20:49 ` Michael Haubenwallner
@ 2009-03-16 14:35   ` Kolesar
  2009-03-16 15:20     ` Andrew Haley
  0 siblings, 1 reply; 10+ messages in thread
From: Kolesar @ 2009-03-16 14:35 UTC (permalink / raw)
  To: gcc-help


Thanks for answer

I'm gave up from statically linked ldrmod :)

But, now i have new problem :)

Before dlopen(), i set LD_LIBRARY_PATH with putenv(), but i get error:
dlopen(sysnfop1s.so) error [2]: libdrmod.so: cannot open shared object file:
No such file or directory.

How i can set library path where is located my library (libdrmod)?

BR
//Kolesar


Michael Haubenwallner wrote:
> 
> On Thu, 2009-03-12 at 08:39 -0700, Kolesar wrote:
>> Hi All
>> 
>> I try linked shared library, statically, but i get error. Where I made
>> mistake? Please help.
>> 
>> Exactly, I want dynamically linked -ldl -lrt -luuid -lm -ldl, and
>> statically
>> linked -ldrmod (libdrmod.so)
> 
> As far as I can tell, statically linking a shared library does not work
> for example on Linux, Solaris, HP-UX, Windows.
> The only platform I know of being able to do that is AIX.
> 
>> g++ -static -ldl -lrt -luuid -lm -ldl -o
>> /home/asimh/my_program/src/.bin/sysnfop1s.so
>> -L/home/asimh/my_program/lib/.bin -ldrmod
>> 
>> /usr/bin/ld: cannot find -ldrmod
> 
> When switched to static linking, the linker does not search for your
> libdrmod.so, but libdrmod.a only (even on AIX), which simply does not
> exist.
> 
> HTH,
> /haubi/
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Statically-linked-shared-library-tp22478672p22539583.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Statically linked shared library
  2009-03-16 14:35   ` Kolesar
@ 2009-03-16 15:20     ` Andrew Haley
  2009-03-16 18:42       ` Kolesar
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Haley @ 2009-03-16 15:20 UTC (permalink / raw)
  To: Kolesar; +Cc: gcc-help

Kolesar wrote:
> Thanks for answer
> 
> I'm gave up from statically linked ldrmod :)
> 
> But, now i have new problem :)
> 
> Before dlopen(), i set LD_LIBRARY_PATH with putenv(), but i get error:
> dlopen(sysnfop1s.so) error [2]: libdrmod.so: cannot open shared object file:
> No such file or directory.
> 
> How i can set library path where is located my library (libdrmod)?

dlopen() takes a full pathname.  dlopen("/lib/foo/bar.so");

Andrew.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Statically linked shared library
  2009-03-16 15:20     ` Andrew Haley
@ 2009-03-16 18:42       ` Kolesar
  2009-03-16 18:48         ` Andrew Haley
  0 siblings, 1 reply; 10+ messages in thread
From: Kolesar @ 2009-03-16 18:42 UTC (permalink / raw)
  To: gcc-help


I use full path for sysnfop1s.so, but sysnfop1s.so have dependencies fod
libdrm.so
ldd sysnfop1s.so
libdrm.so => /my/path/to/libdrm.so

BR
Kolesar

Andrew Haley wrote:
> 
> Kolesar wrote:
>> Thanks for answer
>> 
>> I'm gave up from statically linked ldrmod :)
>> 
>> But, now i have new problem :)
>> 
>> Before dlopen(), i set LD_LIBRARY_PATH with putenv(), but i get error:
>> dlopen(sysnfop1s.so) error [2]: libdrmod.so: cannot open shared object
>> file:
>> No such file or directory.
>> 
>> How i can set library path where is located my library (libdrmod)?
> 
> dlopen() takes a full pathname.  dlopen("/lib/foo/bar.so");
> 
> Andrew.
> 
> 

-- 
View this message in context: http://www.nabble.com/Statically-linked-shared-library-tp22478672p22541475.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Statically linked shared library
  2009-03-16 18:42       ` Kolesar
@ 2009-03-16 18:48         ` Andrew Haley
  2009-04-14 12:32           ` Kolesar
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Haley @ 2009-03-16 18:48 UTC (permalink / raw)
  To: Kolesar; +Cc: gcc-help

Kolesar wrote:
> I use full path for sysnfop1s.so, but sysnfop1s.so have dependencies fod
> libdrm.so
> ldd sysnfop1s.so
> libdrm.so => /my/path/to/libdrm.so

Please don't top-post, it's very confusing.

You have to set LD_LIBRARY_PATH before execution starts, so the easiest
way to solve this problem is with a wrapper script:

#!/bin/sh
LD_LIBRARY_PATH= ...
exec foo

The alternatives are using execv(3) in your program after setting the path
or using -rpath when linking your program.

Andrew.


> Andrew Haley wrote:
>> Kolesar wrote:
>>> Thanks for answer
>>>
>>> I'm gave up from statically linked ldrmod :)
>>>
>>> But, now i have new problem :)
>>>
>>> Before dlopen(), i set LD_LIBRARY_PATH with putenv(), but i get error:
>>> dlopen(sysnfop1s.so) error [2]: libdrmod.so: cannot open shared object
>>> file:
>>> No such file or directory.
>>>
>>> How i can set library path where is located my library (libdrmod)?
>> dlopen() takes a full pathname.  dlopen("/lib/foo/bar.so");
>>
>> Andrew.
>>
>>
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Statically linked shared library
  2009-03-16 18:48         ` Andrew Haley
@ 2009-04-14 12:32           ` Kolesar
  2009-04-14 13:05             ` Andrew Haley
  0 siblings, 1 reply; 10+ messages in thread
From: Kolesar @ 2009-04-14 12:32 UTC (permalink / raw)
  To: gcc-help


Hi Andrew
Set LD_LIBRARY_PATH before start application is not good solution for my
problem, because it is a problem for users.
I try with execv, but i do not solved my problem :-(
I try -rpath too, but, i do not understand howto exactly work -rpath.
:confused:

I read documentation for gcc, but, it is confused for me. Do you have any
example, maybe?

BR
Kolesar


Andrew Haley wrote:
> 
> 
> You have to set LD_LIBRARY_PATH before execution starts, so the easiest
> way to solve this problem is with a wrapper script:
> 
> #!/bin/sh
> LD_LIBRARY_PATH= ...
> exec foo
> 
> The alternatives are using execv(3) in your program after setting the path
> or using -rpath when linking your program.
> 
> Andrew.
> 
> 

-- 
View this message in context: http://www.nabble.com/Statically-linked-shared-library-tp22478672p23038582.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Statically linked shared library
  2009-04-14 12:32           ` Kolesar
@ 2009-04-14 13:05             ` Andrew Haley
  0 siblings, 0 replies; 10+ messages in thread
From: Andrew Haley @ 2009-04-14 13:05 UTC (permalink / raw)
  To: Kolesar; +Cc: gcc-help

Kolesar wrote:

> Set LD_LIBRARY_PATH before start application is not good solution for my
> problem, because it is a problem for users.

That doesn't make any sense.  It's a well-tried technique
used by many programs that works.

> I try with execv, but i do not solved my problem :-(

Well, it works for everyone else.

> I try -rpath too, but, i do not understand howto exactly work -rpath.
> :confused:

gcc -Wl,-rpath,/path/to/directory/that/contains/your/library

See the rpath option in man ld.

Andrew.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Statically linked shared library
@ 2009-03-12 15:39 Kolesar
  0 siblings, 0 replies; 10+ messages in thread
From: Kolesar @ 2009-03-12 15:39 UTC (permalink / raw)
  To: gcc-help


Hi All

I try linked shared library, statically, but i get error. Where I made
mistake? Please help.

Exactly, I want dynamically linked -ldl -lrt -luuid -lm -ldl, and statically
linked -ldrmod (libdrmod.so)


g++ -static -ldl -lrt -luuid -lm -ldl -o
/home/asimh/my_program/src/.bin/sysnfop1s.so
-L/home/asimh/my_program/lib/.bin -ldrmod

/usr/bin/ld: cannot find -ldrmod





-- 
View this message in context: http://www.nabble.com/Statically-linked-shared-library-tp22478671p22478671.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-04-14 13:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-12 15:39 Statically linked shared library Kolesar
2009-03-13 17:21 ` Axel Freyn
2009-03-14 20:49 ` Michael Haubenwallner
2009-03-16 14:35   ` Kolesar
2009-03-16 15:20     ` Andrew Haley
2009-03-16 18:42       ` Kolesar
2009-03-16 18:48         ` Andrew Haley
2009-04-14 12:32           ` Kolesar
2009-04-14 13:05             ` Andrew Haley
2009-03-12 15:39 Kolesar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).