Thread: UNIX C Compile Error
01-01-2004, 01:26 PM #1Zach_CGuestUNIX 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.
01-01-2004, 11:08 PM #2
- 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
01-07-2004, 01:40 PM #3plungerGuest
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 extension...you 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
01-07-2004, 02:43 PM #4
- 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.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
By programmaster in forum OS X - Development and DarwinReplies: 5Last Post: 11-15-2011, 11:16 AM
By Lego in forum OS X - Operating SystemReplies: 0Last Post: 06-10-2010, 05:22 AM
By jimz in forum OS X - Development and DarwinReplies: 2Last Post: 05-16-2008, 05:08 AM
By heavensent in forum OS X - Development and DarwinReplies: 0Last Post: 07-06-2007, 04:55 AM