public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Problem In compiling C++ codes
@ 2001-02-23 10:13 aaboulhosn
  2001-02-23 10:43 ` sherry
  2001-02-23 17:43 ` Problem In compiling C++ codes llewelly_nospam_
  0 siblings, 2 replies; 4+ messages in thread
From: aaboulhosn @ 2001-02-23 10:13 UTC (permalink / raw)
  To: help-gcc

---------------------- Forwarded by AREF ABOULHOSN/F47621C/VEND/FEDEX on
02/23/2001 01:13 PM ---------------------------


AREF ABOULHOSN
02/23/2001 08:55 AM

To:   David T-G <davidtg@bigfoot.com>
cc:

Subject:  Re: Problem In compiling C++ codes  (Document link: AREF
      ABOULHOSN)

Hello Sherry and David

I tried all the procedures you gave me, Thank you very much  for your help
( But I still having some problem)
That's where I am now.
The problem is:
 when I Type :   a.out       or         ./a.out

 It works for   C  and runs the program

But , when, I compile in C++   ,   no errors,   But, when I  type:    a.out
or   ./a.out
It give me  this Error:
ld.so.1 :  a.out:  fatal:  libstdc++.so.2.10.0: open failed: No such file
or directory

I checked my PATH:
PATH=/usr/bin:/usr/local/:/usr/local/lib

libstdc++.so.2.10.0   exist under    this directory:
/usr/local/lib

I tired to copy : libstdc++.so.2.10.0  to the directory where  a.out is  ,
(as a test)it does not help
Thank you
I appreciate it if you , continue working with me until I resolve this
problem

AREF



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

* Re: Problem In compiling C++ codes
  2001-02-23 10:13 Problem In compiling C++ codes aaboulhosn
@ 2001-02-23 10:43 ` sherry
       [not found]   ` <3A96C865.B89CCA77@magma-da.com>
  2001-02-23 17:43 ` Problem In compiling C++ codes llewelly_nospam_
  1 sibling, 1 reply; 4+ messages in thread
From: sherry @ 2001-02-23 10:43 UTC (permalink / raw)
  To: aaboulhosn, help-gcc

aaboulhosn@entpm2.prod.fedex.com wrote:

> But , when, I compile in C++   ,   no errors,   But, when I  type:    a.out
> or   ./a.out
> It give me  this Error:
> ld.so.1 :  a.out:  fatal:  libstdc++.so.2.10.0: open failed: No such file
> or directory
>

ld is gnu linker.
man ld will give you a lot of information about what it is and how it works.

So , to me it seems like you linked your executable with dynamic library,
and the linker can not find your library at run time.
(I hope David correct s me, if I am wrong again)
Now the linker does not use PATH to find the dynamic libraries on your system
but you can specify the path using -L option when linking (ld man pages again)

You can also link your program staticly , you should also know the difference
between
static and dynamic linking and advantages and disadvantages of each. (g++ man
pages for static linking)
(depending on you requirements one may be better than the other ......)

There is also the -rpath option that can be set when linking to help the
linker to find the
runtime libraries (check out man ld)
Did you read g++ man pages ? ... you must read it carefully

Another handy command to know is ldd , try
ldd ./a.out
to see what libraries are linked to your executable. (do not forget man ldd
;) )

>
> I checked my PATH:
> PATH=/usr/bin:/usr/local/:/usr/local/lib
>
> libstdc++.so.2.10.0   exist under    this directory:
> /usr/local/lib
>
> I tired to copy : libstdc++.so.2.10.0  to the directory where  a.out is  ,
> (as a test)it does not help

This won't help ;)

>
> Thank you
> I appreciate it if you , continue working with me until I resolve this
> problem
>
> AREF

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

* Using an external linker [how ?]
       [not found]     ` <3A96D3E8.57328DDA@zeroknowledge.com>
@ 2001-02-23 14:09       ` David Berthelot
  0 siblings, 0 replies; 4+ messages in thread
From: David Berthelot @ 2001-02-23 14:09 UTC (permalink / raw)
  To: gcc-help

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1915 bytes --]

First of all thanks to Sherry for the help she offered me.
But I think I need to go a bit deeper because it doesn't solve
my problem (so far).

I want to use ild "sun incremental linker" to link the output
of g++ (on sun). But, it doesn't work ! So I describe how I proceed.

I did something like this:
> setenv PATH .:<path_to_g++_binaries>
> ln -s /<path_to_ild>/ild ld
> g++ -no-gnu-linker -c *.C
> g++ -v -no-gnu-linker -o toto.exe *.o
[... lot of debug information...]

First surprise ild is not invoked, Solaris' ld is invoked instead !
But this executable (main.exe) works fine.

then I tried just to type the line "collect2 ..." that appears in the verbose
information
produced by last line:
> collect2 ......

Then (why ?) ild is invoked this time. But the new executable doesn't work.
> main.exe
Segmentation Fault.

And a look at the crash trace (gdb):
(gdb) bt
#0  0x0 in ?? ()
#1  0x112dc in __do_global_ctors_aux ()
#2  0x1100c in _init ()

So it still seems to be related to the global constructors

So if anyone has any idea, I would be grateful since I tried everything I thought of !

Thanks,

David.

Sherry:

> g++ man pages:
>
> >       -fno-gnu-linker
> >               Do  not  output global initializations (such as C++
> >               constructors and destructors) in the form  used  by
> >               the  GNU linker (on systems where the GNU linker is
> >               the standard method of handling  them).   Use  this
> >               option when you want to use a non-GNU linker, which
> >               also requires using the collect2  program  to  make
> >               sure  the  system  linker includes constructors and
> >               destructors.  (collect2 is included in the  GNU  CC
> >               distribution.)   For  systems  which  must use col­
> >               lect2, the compiler driver gcc is configured to  do
> >               this automatically.

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

* Re: Problem In compiling C++ codes
  2001-02-23 10:13 Problem In compiling C++ codes aaboulhosn
  2001-02-23 10:43 ` sherry
@ 2001-02-23 17:43 ` llewelly_nospam_
  1 sibling, 0 replies; 4+ messages in thread
From: llewelly_nospam_ @ 2001-02-23 17:43 UTC (permalink / raw)
  To: aaboulhosn; +Cc: help-gcc

[snip]
> libstdc++.so.2.10.0   exist under    this directory:
> /usr/local/lib
[snip]

Under most unices, you need to have the directories containing your
  shared libs in the LD_LIBRARY_PATH variable.

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

end of thread, other threads:[~2001-02-23 17:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-23 10:13 Problem In compiling C++ codes aaboulhosn
2001-02-23 10:43 ` sherry
     [not found]   ` <3A96C865.B89CCA77@magma-da.com>
     [not found]     ` <3A96D3E8.57328DDA@zeroknowledge.com>
2001-02-23 14:09       ` Using an external linker [how ?] David Berthelot
2001-02-23 17:43 ` Problem In compiling C++ codes llewelly_nospam_

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