Results 1 to 4 of 4
  1. #1
    UNIX C Compile Error
    Sorry to ask on such a simple question, I'm new to UNIX and Macs although I am enjoying my switch from Windows. Here is my problem. Whenever I right a program in C++ or C I can not get it to run. Here is everything I do. I write the code in pico and save it in the appropriate file format in this case pawn.c. I can see the file in Apple's finder and it has a big C on it so I am assuming I did not mess up here. I then run Terminal and change to the appropriate directory hit ls to make sure and finally compile by typing cc pawn.c -o pawn

    It all seems to go well. I go right back to the terminal prompt Zach [], but when I type pawn I get a bad command. So I looked at it in finder and it is just the standard white piece of paper icon and does not have a file extension when I go to get info.

    Excuse my ignorance or references to Windows machines but shouldn't it be a .exe? Am I messing up in compiling. I checked online tutorials and they say to do it the way I did but my attempt was in vain. Any help is greatly appreciated.

  2. #2

    rman's Avatar
    Member Since
    Dec 24, 2002
    Los Angeles, California
    2 x 3.0GHz Quad-Core, 6GB OS X 10.6.8 | 15in MacBook Pro 2.2GHz OS X 10.6.8 | 64GB iPad 2 WiFi
    Check the directory where you compiled the program. You should find a file call pawn, as you said. To execute the file just enter at the prompt the following: ./pawn. That is dot slash pawn

  3. #3
    congrats on your switch! I am not much of a c programmer but I do spend a good bit of time on the command line of unix/linux machines. A few things to keep in mind:

    ->neither unix nor OS X could care less about a .exe could call the file little.willie_is_evil and unix wouldn't care as long as you have execute permission over the file.

    ->from the command line: ls -al
    ->this will show you all of the files in your current directory and their respective permissions and ownership.

    ->from the command line: man chmod
    -> this will tell you more about changing ownership and permissions
    -> you will probably want to do something like: chmod u+x ./pawn or chmod 711 ./pawn

    -> once you have execut permissions (-rwxr--r-- or something like it) then you can just follow rman's advice and enter from the command line: ./pawn

    -good luck!


  4. #4

    Graphite's Avatar
    Member Since
    Feb 25, 2003
    Tropical Island, Jealous?
    MacPro 3.0Ghz 16GB RAM, 4x256 Vid, 30''cinema display
    try out apple developer tools, and write your program in there. I hvn't had a problem with it aside from me screwing up a path or other error caused by me.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How do I compile source code on a mac Im trying to compile hydra 7.1.src.tar.gz on a
    By programmaster in forum OS X - Development and Darwin
    Replies: 5
    Last Post: 11-15-2011, 10:16 AM
  2. Replies: 0
    Last Post: 06-10-2010, 04:22 AM
  3. C++ compile error
    By jimz in forum OS X - Development and Darwin
    Replies: 2
    Last Post: 05-16-2008, 04:08 AM
  4. could some one compile something for me
    By heavensent in forum OS X - Development and Darwin
    Replies: 0
    Last Post: 07-06-2007, 03:55 AM

Posting Permissions

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