Find the answer to your Linux question:
Results 1 to 5 of 5
Ok I am pretty new to linux, but have done java and c++ programming in a unix-like enviroment before via ssh. I am trying to run a simple c++ that ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2005
    Location
    Tucson, AZ, USA
    Posts
    3

    need help running compiled c++ code


    Ok I am pretty new to linux, but have done java and c++ programming in a unix-like enviroment before via ssh. I am trying to run a simple c++ that I have compiled in the following way.

    Code:
    c++ -o hello hello.cpp
    when I do this it makes a file in the current directory called:
    hello*

    now usually to run the program I would just type hello in the shell and it would run the program right? but when i do type hello I get this:

    bash: hello: command not found
    Thank you for any help and your patience helping out a linux-newbie,

    Jeremy

  2. #2
    Linux Newbie
    Join Date
    Aug 2004
    Posts
    220
    are you typeing:

    hello

    or

    ./hello

    ?

    ./ means "in this directory"

  3. #3
    Linux Guru bryansmith's Avatar
    Join Date
    Nov 2004
    Location
    /Ontario/Canada
    Posts
    2,619
    Like robotics56a said, you will have to type:
    Code:
    ./<program name>
    You will have to be in the directory of the compiled program for that to work.

    Bryan
    Looking for a distro? Look here.
    "There can be no doubt that all our knowledge begins with experience." - Immanuel Kant (Critique of Pure Reason)
    Queen's University - Arts and Science 2008 (Sociology)
    Registered Linux User #386147.

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    May 2005
    Location
    Tucson, AZ, USA
    Posts
    3
    doooow Thanks guys for the quick response!!!

  6. #5
    Linux Guru bryansmith's Avatar
    Join Date
    Nov 2004
    Location
    /Ontario/Canada
    Posts
    2,619
    No problem, glad to help.

    Bryan
    Looking for a distro? Look here.
    "There can be no doubt that all our knowledge begins with experience." - Immanuel Kant (Critique of Pure Reason)
    Queen's University - Arts and Science 2008 (Sociology)
    Registered Linux User #386147.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •