Running compiled programs on XDarwin?

2002-09-13
2002-09-13
  • Jonathan Tan
    Jonathan Tan
    2002-09-13

    my uni uses UNIX computer systems, like most others i reckon, for its computer science students, and while i'm there, all tt i really need to do to compile and run a program, is to type:

    gcc source.c -o program_name

    let it finish compiling, and then type:

    program_name

    not able to do this in XDarwin though... it simply says tt it is an unrecognized command. and trying to open the compiled program by double clicking in the finder just gives me a choose application to open with dialog box...

    sorry about all these newbie questions, but i was hoping to find out if it is possible to do this?
    thanks. =D

     
    • Not too related to XDarwin (which is the free X11 server that runs on top of Mac OS X), but I think I see your problem, and it's a fairly common one with newbies.

      Try launching your program by typing

      ./program_name

      instead, and that should work. The reason for this discrepancy takes some explaining...

      When the shell searches for commands to execute, it searches through all the directories in your path. On Mac OS X Jaguar, these directories are by default /bin, /sbin, /usr/bin and /usr/sbin. It is common to add other directories such as /usr/local/bin and (for XDarwin /usr/X11R6/bin). Now, most people assume that a program in your current directory will be found anyway (because it seems logical, and MS-DOS did it this way, etc). By default this is not so, but your university may have configured their setup to make commands in the current directory to always be found. Another way is to add ~/bin to the path and make sure all programs are compiled inside ~/bin. The directory "." is a shortcut for the current directory, so ./program_name will work.