This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: getting started 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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]