public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* getting started help!
@ 2004-01-05 19:00 Rutledge, Jack R Contractor OPM LIS
       [not found] ` <B701B4A2CE580D449E6C5D38C1C84AAB069C90AA@n3cdoimmail30m.ho od.army.mil>
  2004-01-06 12:20 ` Torsten Reuss
  0 siblings, 2 replies; 4+ messages in thread
From: Rutledge, Jack R Contractor OPM LIS @ 2004-01-05 19:00 UTC (permalink / raw)
  To: 'gcc-help@gcc.gnu.org'

Hello, I am trying to find some help with the gcc 3.2.  I have written a
little c++ code before, but always inside of an IDE.  I am currently working
on a Solaris 9 x86 OS and do not have an IDE.  I have installed the gcc 3.2
version that came with the Solaris media kit.

Once everything was installed, I tried to simply test out the installation.
I wrote a simple little one liner program, and after many headaches, I
finally got it to compile.  The program is listed below.

Program name:  jr.cpp
#include <iostream>
int main (void)
{
  std::cout<<"It works!";
  return 1;
}

Once it compiled and created the a.out file, I tried to execute it.  I got
the following result.

I tried simply typing a.out, it says "a.out: not found"
I also tried ./a.out with a result of "ld.so.1: ./a.out: fatal:
libstdc++.so.5: open failed: No such file or directory killed"

I am unsure what it is that I am doing wrong, and would appreciate any help
that you might give me.  Also, is there any type of instructional book for
beginners using the gcc compiler collection?

thanks,


Jack R. Rutledge

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

* Re: getting started help!
       [not found] ` <B701B4A2CE580D449E6C5D38C1C84AAB069C90AA@n3cdoimmail30m.ho od.army.mil>
@ 2004-01-05 19:41   ` Andrea 'Fyre Wyzard' Bocci
  0 siblings, 0 replies; 4+ messages in thread
From: Andrea 'Fyre Wyzard' Bocci @ 2004-01-05 19:41 UTC (permalink / raw)
  To: Rutledge, Jack R Contractor OPM LIS; +Cc: 'gcc-help@gcc.gnu.org'

This works (on my Linux box)

[fwyzard@localhost test]$ cat test.cc
#include <iostream>
int main (void)
{
   std::cout << "It works!" << std::endl;
   return 0;
}

[fwyzard@localhost test]$ g++ test.cc -o test
[fwyzard@localhost test]$ ./test
It works!
[fwyzard@localhost test]$

Note: the changes I've made to your code are purely aesthetycal - a "\n" 
after the cout and an exit coe of 0 indicating success...


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

* Re: getting started help!
  2004-01-05 19:00 getting started help! Rutledge, Jack R Contractor OPM LIS
       [not found] ` <B701B4A2CE580D449E6C5D38C1C84AAB069C90AA@n3cdoimmail30m.ho od.army.mil>
@ 2004-01-06 12:20 ` Torsten Reuss
  1 sibling, 0 replies; 4+ messages in thread
From: Torsten Reuss @ 2004-01-06 12:20 UTC (permalink / raw)
  To: Rutledge, Jack R Contractor OPM LIS; +Cc: gcc-help

Hi Jack,

In addition to Lyle's answer, I also want to point out one very useful UNIX
(Well, Linux + Solaris) command for problems with libraries, which is ldd.
ldd shows you what libraries your program is linked to.

See below transcript which shows your problem and how to use ldd to detect
what libraries a program needs:

[treuss]src>cat hello.cc
#include <iostream>

int main( int argc, char* argv[] )
{
        std::cout << "Hello World" << std::endl;
        return 0;
}

[treuss]src>g++ -o hello hello.cc
[treuss]src>ldd hello
        libstdc++.so.2.10.0 =>   (file not found)
        libm.so.1 =>     /usr/lib/libm.so.1
        libc.so.1 =>     /usr/lib/libc.so.1
        libdl.so.1 =>    /usr/lib/libdl.so.1
        /usr/platform/SUNW,UltraAX-i2/lib/libc_psr.so.1
[treuss]src>./hello
ld.so.1: ./hello: fatal: libstdc++.so.2.10.0: open failed: No such file or
directory
Killed
[treuss]src>export LD_LIBRARY_PATH=/usr/local/lib
[treuss]src>ldd hello
        libstdc++.so.2.10.0 =>   /usr/local/lib/libstdc++.so.2.10.0
        libm.so.1 =>     /usr/lib/libm.so.1
        libc.so.1 =>     /usr/lib/libc.so.1
        libdl.so.1 =>    /usr/lib/libdl.so.1
        /usr/platform/SUNW,UltraAX-i2/lib/libc_psr.so.1
[treuss]src>./hello
Hello World
[treuss]src>

Best regards,
                        Torsten

> Hello, I am trying to find some help with the gcc 3.2.  I have written a
> little c++ code before, but always inside of an IDE.  I am currently
> working
> on a Solaris 9 x86 OS and do not have an IDE.  I have installed the gcc
> 3.2
> version that came with the Solaris media kit.
> 
> Once everything was installed, I tried to simply test out the
> installation.
> I wrote a simple little one liner program, and after many headaches, I
> finally got it to compile.  The program is listed below.
> 
> Program name:  jr.cpp
> #include <iostream>
> int main (void)
> {
>   std::cout<<"It works!";
>   return 1;
> }
> 
> Once it compiled and created the a.out file, I tried to execute it.  I got
> the following result.
> 
> I tried simply typing a.out, it says "a.out: not found"
> I also tried ./a.out with a result of "ld.so.1: ./a.out: fatal:
> libstdc++.so.5: open failed: No such file or directory killed"
> 
> I am unsure what it is that I am doing wrong, and would appreciate any
> help
> that you might give me.  Also, is there any type of instructional book for
> beginners using the gcc compiler collection?
> 
> thanks,
> 
> 
> Jack R. Rutledge
> 

-- 
+++ GMX - die erste Adresse für Mail, Message, More +++
Neu: Preissenkung für MMS und FreeMMS! http://www.gmx.net


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

* RE: getting started help!
@ 2004-01-05 19:10 lrtaylor
  0 siblings, 0 replies; 4+ messages in thread
From: lrtaylor @ 2004-01-05 19:10 UTC (permalink / raw)
  To: Jack.Rutledge, gcc-help

Jack,

I'm not sure of any specific instructional book, but you can find books on UNIX development out there.  In particular, you might take a look at some of the books for development on Linux.  Much of what you find there concerning the compiler, Makefiles, etc., will also apply to you, even though you're working on Solaris.  You might also take a look at getting KDE running on your box and using the KDevelop IDE.  It's a nice place to start, if you're just learning the ropes.

Your problem below is due to the fact that the library libstdc++.so.5 is not in your LD_LIBRARY_PATH.  You probably have GCC installed somewhere other than /usr, so the library was not placed in /usr/lib, and hence is not in your default library search path.  What you need to do is add the path to the library to the LD_LIBRARY_PATH environment variable.  For example, if your GCC was installed in /usr/local, then you would need to add /usr/local/lib to LD_LIBRARY_PATH like this:

If you are using the Korn or Bash shell:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

If you are using the C shell:
setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/local/lib

Once you do this, it should pick up the library and run.  Note that you'll have to use the correct path for your installation.

A couple other points that could be useful to you:

	The reason that it couldn't find the program when you simply typed a.out is because the current working directory is not in your path.  This is generally a good thing, but it can be added by simply adding "." to your PATH environment variable (similar to how it was done for LD_LIBRARY_PATH).

	1 (one) is considered and error exit status for programs on UNIX.  Generally, 0 (zero) is used to indicate success.  Any other return value indicates an error.  This is not always important, but is something that you need to keep in mind if you ever plan to test for the exit status of your program - especially when doing so in standard ways, such as with an if statement, etc.

Good luck!
Lyle

-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]On
Behalf Of Rutledge, Jack R Contractor OPM LIS
Sent: Monday, January 05, 2004 12:00 PM
To: 'gcc-help@gcc.gnu.org'
Subject: getting started help!


Hello, I am trying to find some help with the gcc 3.2.  I have written a
little c++ code before, but always inside of an IDE.  I am currently working
on a Solaris 9 x86 OS and do not have an IDE.  I have installed the gcc 3.2
version that came with the Solaris media kit.

Once everything was installed, I tried to simply test out the installation.
I wrote a simple little one liner program, and after many headaches, I
finally got it to compile.  The program is listed below.

Program name:  jr.cpp
#include <iostream>
int main (void)
{
  std::cout<<"It works!";
  return 1;
}

Once it compiled and created the a.out file, I tried to execute it.  I got
the following result.

I tried simply typing a.out, it says "a.out: not found"
I also tried ./a.out with a result of "ld.so.1: ./a.out: fatal:
libstdc++.so.5: open failed: No such file or directory killed"

I am unsure what it is that I am doing wrong, and would appreciate any help
that you might give me.  Also, is there any type of instructional book for
beginners using the gcc compiler collection?

thanks,


Jack R. Rutledge

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

end of thread, other threads:[~2004-01-06 12:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-05 19:00 getting started help! Rutledge, Jack R Contractor OPM LIS
     [not found] ` <B701B4A2CE580D449E6C5D38C1C84AAB069C90AA@n3cdoimmail30m.ho od.army.mil>
2004-01-05 19:41   ` Andrea 'Fyre Wyzard' Bocci
2004-01-06 12:20 ` Torsten Reuss
2004-01-05 19:10 lrtaylor

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