public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* LD_LIBRARY_PATH needed for gcc-3.4.5 executable
@ 2006-05-25 21:31 David M. O'Brien
  2006-05-26  6:17 ` Digvijoy Chatterjee
  0 siblings, 1 reply; 3+ messages in thread
From: David M. O'Brien @ 2006-05-25 21:31 UTC (permalink / raw)
  To: gcc-help

Can anyone suggest a fix for this??


I am compiling a program with gcc-3.4.5 g++.
When I go to execute that program I get the following:

ld.so.1: ./prog1: fatal: libstdc++.so.6: open failed: No such file or directory

I can solve the issue by setting my LD_LIBRARY_PATH to the directory where
libstdc++.so.6 is located.

This program used to run with gcc-2.95.3 without resetting LD_LIBRARY_PATH.

Question I have,

Is there a way to compile my program so that there is no need to have the
libstdc++.so.6 at runtime? Can I create a prog1, that contains all symbols and
no need for this library when executing?

If so, what are the command options for doing that? I have read over the g++ and
ld documentation but can not seem to find the correct combination.

Thanks,
Dave





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

* Re: LD_LIBRARY_PATH needed for gcc-3.4.5 executable
  2006-05-25 21:31 LD_LIBRARY_PATH needed for gcc-3.4.5 executable David M. O'Brien
@ 2006-05-26  6:17 ` Digvijoy Chatterjee
  2006-05-26 10:05   ` Andrew Haley
  0 siblings, 1 reply; 3+ messages in thread
From: Digvijoy Chatterjee @ 2006-05-26  6:17 UTC (permalink / raw)
  To: gcc-help

On 5/26/06, David M. O'Brien <dmo61@lucent.com> wrote:
> Can anyone suggest a fix for this??
>
>
> I am compiling a program with gcc-3.4.5 g++.
> When I go to execute that program I get the following:
>
> ld.so.1: ./prog1: fatal: libstdc++.so.6: open failed: No such file or directory
>
> I can solve the issue by setting my LD_LIBRARY_PATH to the directory where
> libstdc++.so.6 is located.
>
> This program used to run with gcc-2.95.3 without resetting LD_LIBRARY_PATH.
>
> Question I have,
>
> Is there a way to compile my program so that there is no need to have the
> libstdc++.so.6 at runtime? Can I create a prog1, that contains all symbols and
> no need for this library when executing?
>
> If so, what are the command options for doing that? I have read over the g++ and
> ld documentation but can not seem to find the correct combination.
>
> Thanks,
> Dave
hi Dave ,
You can link it statically if you are ready to have a huge executable,
if you do  that then Dynamic Linking would not be needed at all ,all
the linking would be built inside the executable
I think -static is the switch to do that
HTH
Digz

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

* Re: LD_LIBRARY_PATH needed for gcc-3.4.5 executable
  2006-05-26  6:17 ` Digvijoy Chatterjee
@ 2006-05-26 10:05   ` Andrew Haley
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Haley @ 2006-05-26 10:05 UTC (permalink / raw)
  To: Digvijoy Chatterjee; +Cc: gcc-help

Digvijoy Chatterjee writes:
 > On 5/26/06, David M. O'Brien <dmo61@lucent.com> wrote:
 > > Can anyone suggest a fix for this??
 > >
 > >
 > > I am compiling a program with gcc-3.4.5 g++.
 > > When I go to execute that program I get the following:
 > >
 > > ld.so.1: ./prog1: fatal: libstdc++.so.6: open failed: No such file or directory
 > >
 > > I can solve the issue by setting my LD_LIBRARY_PATH to the directory where
 > > libstdc++.so.6 is located.
 > >
 > > This program used to run with gcc-2.95.3 without resetting LD_LIBRARY_PATH.
 > >
 > > Question I have,
 > >
 > > Is there a way to compile my program so that there is no need to have the
 > > libstdc++.so.6 at runtime? Can I create a prog1, that contains all symbols and
 > > no need for this library when executing?
 > >
 > > If so, what are the command options for doing that? I have read over the g++ and
 > > ld documentation but can not seem to find the correct combination.

 > hi Dave ,
 > You can link it statically if you are ready to have a huge executable,
 > if you do  that then Dynamic Linking would not be needed at all ,all
 > the linking would be built inside the executable
 > I think -static is the switch to do that

Static linkage is problematic on GNU/Linux and similar systems.  If
you must link statically with libstdc++, it's probably better to link
statically only with that library.

You can do that with something like:

  gcc test.cc -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic

but in general we don't recommend static linkage at all.

Andrew.

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

end of thread, other threads:[~2006-05-26 10:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-25 21:31 LD_LIBRARY_PATH needed for gcc-3.4.5 executable David M. O'Brien
2006-05-26  6:17 ` Digvijoy Chatterjee
2006-05-26 10:05   ` Andrew Haley

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).