Running C++ file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ilikesuresh
    New Member
    • Aug 2007
    • 47

    Running C++ file

    Hi,
    I wrote the following c++ program in solaris.
    For compilation i use,
    g++ dup.cpp
    command.But while executing like ./dup or dup ,the error i am getting is
    ld.so.1: dup: fatal: libstdc++.so.5: open failed: No such file or directory
    Killed

    Tell me the reason for this and Is there any other way to execute the cpp program?
    clarify me
  • Laharl
    Recognized Expert Contributor
    • Sep 2007
    • 849

    #2
    The syntax for compilation into an executable is:

    Code:
    g++ *file*.cpp -o *executable name*
    The -o flag tells the compiler to make an executable of name following the -o, which can be run with ./ as normal. Compiling without it just checks for syntactical errors without running the linker, as if you had used the -c flag.

    There are a number of other flags, some of which are very handy. Use man g++ for more information, or consult Google.

    Comment

    • ilikesuresh
      New Member
      • Aug 2007
      • 47

      #3
      Originally posted by Laharl
      The syntax for compilation into an executable is:

      Code:
      g++ *file*.cpp -o *executable name*
      The -o flag tells the compiler to make an executable of name following the -o, which can be run with ./ as normal. Compiling without it just checks for syntactical errors without running the linker, as if you had used the -c flag.

      There are a number of other flags, some of which are very handy. Use man g++ for more information, or consult Google.
      Even though i compile the file with the same syntax that specified above will not work.I am getting the same error.

      Comment

      • ashitpro
        Recognized Expert Contributor
        • Aug 2007
        • 542

        #4
        Originally posted by ilikesuresh
        Even though i compile the file with the same syntax that specified above will not work.I am getting the same error.
        Check whether "libstdc++.so.5 " is present in /usr/lib or /usr/local/lib
        If it is not there reinstall g++.
        If it is there then check out the permissions.

        Comment

        Working...