running compiled C++ executables in Terminal

Discussion in 'Mac Programming' started by cossie, Mar 29, 2007.

  1. macrumors member

    Joined:
    Aug 8, 2006
    #1
    Morning,

    I'm trying to compile and run some source code in Terminal. It compiles fine using the command

    Code:
    gcc -c -I /home/cossie/ode/include tutorial.cpp -o tutorial
    And I've tried to run the compiled file at the following attempts:

    Code:
    ./tutorial
    
    -bash: ./tutorial: Permission denied
    
    Code:
    sudo ./tutorial
    
    Password:
    
    sudo: ./tutorial: command not found
    
    Can anyone give me any pointers as to what I'm doing wrong? I thought ./ was the way to execute an object file in a Unix environment.

    Thanks,

    Cossie
     
  2. macrumors 6502a

    Palad1

    Joined:
    Feb 24, 2004
    Location:
    London, UK
    #2
    tutorial is missing the exec flag for the current user

    Code:
    chmod u+x tutorial
    more info :
    Code:
    man chmod
     
  3. thread starter macrumors member

    Joined:
    Aug 8, 2006
    #3
    Palad1 thanks a million! I had totally forgotten about setting the permissions!

    I had been using a college account where I had a script running my compiles - which set the permissions - but I can't log into it today, eugh I'm such a muppet!

    Thanks again!
     

Share This Page