Terminal help

okay does anyone know the command to compile a source file in terminal?

Okay. I'm not sure which programming languages you're familiar with. Let's assume we're talking about C or C++. A source file is basically a (plain) text file that you (or someone else) has created. It'll have variables (and, I think, function definitions) declared first, followed by the actual code for the functions. For instance, a simple source file might look something like this (let's call this file hello.cpp):
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
main (int argc, char **argv)
printf("hello, world \n");
exit (0);
The "#include" statements tell the compiler to include some standard code files that handle things like displaying text. The 'main' function is the first function that will be called when the program begins to execute. Basically, this program prints 'hello, world' in your Terminal window and then quits (the program basically ignores any input given when the program starts up.). I think it'll compile.
Now, you can read the program, but computers don't operate on text files. The program has to be compiled into (what is known as) a binary file. This is basically a set of commands that your computer can understand and which looks like gibberish to most of us. The program 'gcc' will take your C or C++ source file and turn it into a binary file (or, as I referred to it before, a compiled program). So, after you create the plain text file above (I just use project builder, included with the developer tools. Any program that creates plain text files should work just fine), navigate to the folder containing your hello.cpp files and type
gcc -g -Wall -o hello hello.cpp
After a second, your command prompt should reappear, and you can type:
./hello
'hello world' should appear under your command prompt. The command './hello' instructs the computer to run the program 'hello' that is found in the current folder (the '.' denotes the current directory, so you don't have to type out /users/you/...../hello).
As for your second question, gcc should be able to compile any C or C++ files, which end in one of these: .c .cp .cpp .cxx .C .cc .c++
I hope this helps.
-Anthony
Dual 1.25 GHZ G4/FW 800   Mac OS X (10.4.5)  

Similar Messages

  • Terminal help (i'm a newbie, too)

    Ok. i've been using firefox as my browser and i have to start it in safemode to fix an extension problem/bad profile. while going through the troubleshooting steps, i eventually reached this: "go to your Terminal and run:
    /Applications/Firefox.app/Contents/MacOS/firefox -safe-mode"
    well, i did that (using the correct folder string, but nothing happened except for ">" to appear on the next line after i hit enter. how the heck do i get the program to launch? i'm really lost when it comes to Terminal. i'm not an ubergeek and i'm not someone who's using a computer for the first time, either. i know my way around terminology pretty well, so anyone who can help, don't worry about trying to explain it to a novice.
    thanks.

    Hi tjcarty,
       What Brant is trying to tell you is that you generally see the PS2 prompt, '>', when you fail to close a quote. However, you've made precision difficult. If you post the exact command that you executed, we might be able to help.
    Gary
    ~~~~
          God decided to take the devil to court and
       settle their differences once and for all.
          When Satan heard of this, he grinned and said, "And
       just where do you think you're going to find a lawyer?"

  • Resizing DMG with Terminal help needed

    I've got a DMG file with read/write privileges that I need to increase the size of. I've done a bunch of searching, both here and on the net, and the best I can find is a Terminal script, something I know nothing about. Here's the script I found:
    hdiutil resize -size 25g /PATH/TO/DISK/IMAGE.dmg
    But before I toss this into terminal with the modifications to make it work for mine, I just wanted to make sure I was doing everything right.
    First, the path. The actual path is /Prima/Users/Doug/Desktop/work.dmg, that's how I type it? I've also seen just ~/Desktop/work.dmg so I figured I'd double check that.
    Also, 25g, I have no idea what that measurement is since I've seen gb and a few other ones when I tried to search the script a bit more. I want 2.6GB, what would I need for that?
    Finally, I'm guessing the "hdiutil" is just telling it that this is going to be working on a volume but I wanted to make sure that I had that right.
    Any help you guys can give me would be great! Or if you can tell me another non-Terminal way to do this that'd be even better!
    15" MacBook Pro 2.33GHz, 2GB RAM, 160GB internal, glossy.   Mac OS X (10.4.8)   1TB My Book Premium II and DVD±RW DL LaCie Burner

    Nevermind.
    hdiutil resize -size 2.6g ~/Desktop/my.dmg
    That did it.

  • Terminal help - accidentally deleted /System/Library/Extensions

    So I foolishly deleted my entire Extensions folder. I only trashed it though, not emptied. But I can't boot up. The only way I can get into anything is by using the retail Snow Leopard CD. From here I can get to the terminal.
    So...
    Can I restore my files from the trash via the terminal in the install cd?
    I've been trying some commands but no luck so far.
    Help is greatly appreciated.

    Perfect. It took a little tweaking. First I had to create the "Extensions" directory again, and even then it wouldn't let me move a whole directory, just individual files. The "-R" command worked that out though.
    The full code I ended up using was...
    cp -R /Volumes/"Hard Drive"/.Trashes/*/Extensions /Volumes/"Hard Drive"/System/Library/Extensions

  • Terminal help, wont stay open

    every time i try to open terminal the screen appears for a brief second and then dissapears, and will contine to do this when u try to do anything. i recorded the screen and when i looked and it in slow motion it says this on the page header
    telnet park 17 secureserver.net--bash--(apple symbol)1
    and this in the text part
    last login: tue sep 26 on ttyp1
    /applications/virtual\pc.app/contents/macos/virtual\pc;exit
    welcome to darwin
    tink:~michelle$/applications/virtual\pc.app/contents/macos/virtual\pc;exit
    ~bash:/applications/virtual\pc.app/contents/macos/virtual\pc; no such file or directoy
    logout
    can anyone help me what is this and how do i stop it

    i had the same problem with iChat for a while and still haven't figured out what's wrong with it.
    Then it started happening to iTunes...
    then my programs tray dissapeared.
    now my mac won't boot up (stuck at the pinwheel loading screen with the apple above it) and safe mode won't work. this is my first mac after switching from PCs. good game macs.

  • Terminal help to fix Java

    I am having the hardest time figuring this out. I've searched for a few hours now and keep finding things about doing this or that in terminal. The only problem is that I'm not that guy. I don't know this stuf. Any help would be greatly appreciated.

    This may help http://www.dmxzone.com/go/16740/clearing-dreamweaver-s-cache/

  • Terminal Help - History!!!!! Please Help!!!!!!

    Hello, I was just wondering if anyone here who knows a bit about Terminal could give me some advice. At the moment when I open terminal and click the up arrow it scrolls through the last commands I typed in (I'm guessing this is the History - Well thats what I'm going to call it!). So I was wondering if there is either a command or option to delete this history - So as when I next open terminal and I click the up-arrow it will just be blank!. Hope someone can help me with this.
    Thanks in Advance
    Adam Jeffreys

    unset HISTFILE
    And yes you should pursue this in the Mac OS X Technologies > Unix Forum
    <http://discussions.apple.com/forum.jspa?forumID=735>

  • Terminal --help (Arch Linux) equivalent?

    Not sure if this is the right place to ask, but as it's an operating system feature I'll give it a shot.
    I am a big fan of Arch Linux especially using the unix commands within the terminal.  One feature I love is being able to simple type '--help' after a command to get a full list of options.  Such as 'ls --help' will bring up the options available for displaying the contents of the directory, like informing me '-a' shows hidden files.
    What I would like to know is there a mac equivalent?  So I can easily see options in terminal.
    Thanks,
    Steve.

    There's really no consistancy.  It depends on the command.  Some actually do accept --help (e.g., gcc, grep -- probably all the gnu derived commands).  Some may look for -? and/or -h.  And some give you their general syntax if you make a syntax error on the command.  But to get a full description (well, hopefully a more full description), as Reed said above use the man command.

  • Terminal help - hard drive rescue

    Hi, I have a little bit of a problem. My hard drive is unbootable, but still mountable. *My goal is to gain access to the hard drive, and copy everything on it to an external hard drive*. Note, because it's unbootable, I don't have a lot of options.
    Also, *the Firewire port on the machine is not working*. Thus, any file transferring must be accomplished over USB or Ethernet. I also have access another Mac, if that would be of any assistance. Now let me throw you some ideas here. (For the record, I don't know if any of this will help, but it's worth a try.) *I have booted the machine off the Leopard Install Disc. This now gives you access to several options:*
    *Startup Disk. Disk Utility. Terminal. System Profiler. Network Profiler.*
    Something tells me Terminal might be able to make some magic happen. Unfortunately, I know nothing about the voodoo commands that can be issued in it to get this plan into action. I hear rumors about something called Single User Mode, however I know very little about it (other than, if entering the wrong command, erasing your drive).
    So if anyone out there has any suggestion as to how to set this up, I'd appreciate it. Thanks.

    How do you know the disk is mountable? Do you see it with Disk Utility when booted with the install disk? Try this, if you downloaded the 10.5.2 COMBO update before experiencing your problem. Boot with the install disk, select your language, select Disk Utility from Utilities->File->Open disk image, select the combo image, mount it, and try to run it, selecting the hosed HD. If you don't have the COMBO update, download it from http://www.apple.com/downloads/macosx/apple/macosx_updates/macosx1052comboupdate .html, and transfer it to the HD via USB or ethernet from another computer. Since you don't have an operable FireWire port, using target disk mode (the preferred option) is out.
    If you can't do the above, then post your Terminal queries to the Unix forum under OS X Technologies where the Terminal and Unix gurus hang out. http://docs.info.apple.com/article.html?artnum=106388 and http://docs.info.apple.com/article.html?artnum=106237 describe single-user mode operations.

  • Installing 'ack' and terminal help

    hey, i'm trying to install ack: http://petdance.com/ack/ but the instructions on the site aren't working:
    curl http://ack.googlecode.com/svn/tags/latest/ack-standalone > ~/bin/ack && chmod 0755 !$
    at work yesterday i asked a linux guy for help to install it on my work machine, but i'm not totally sure how he did it and i can't recreate what he did at home now. i get the gist of what is supposed to be happening but no matter what directory i put as the target path it says either "No such file or directory" or "Permission denied." i've tried /bin, /usr/local/bin, /usr/bin, and created a directory /usr/local/ack but it still won't DL. i'm sure i'm missing something simple about terminal/unix but i've been trying to figure this out for hours over the past few nights and google is no help. i have tried prefacing the commands with sudo as well but still get the same responses. i appreciate any help, even if it's a pointer to material to read.
    thanks,
    joe

    Based on the curl line you displayed
    curl http://ack.googlecode.com/svn/tags/latest/ack-standalone > ~/bin/ack && chmod 0755 !$
    the file should be in $HOME/bin
    If you did not have a $HOME/bin already, then maybe it did not download.
    I found that when I ran the command, the *chmod 0755 !$ * failed. I had to manually run:
    chmod 0755 $HOME/bin/ack
    in order to make the script executable.
    If you do not want ack to be in $HOME/bin, then pick some other destination.
    Once you have the ack script and its permissions are -rwxr-xr-x make sure that the directory holding ack is in your PATH environment variable.
    Typically the 2 conventional locations for Unix commands you install would be $HOME/bin and /usr/local/bin either of which would need to be added to PATH

  • Terminal help [SOLVED]

    Hi,
    I'm (relatively) new here, been using Arch for about 6 months and I have found "my" ditsro!  One quick and probably stupid question:  In screenshots I see a cool arch logo in the terminal.  How do you get this?
    Thanks,
    Jim
    Last edited by Divingstar (2008-03-26 01:51:15)

    Do you mean the screenshot info grabber?
    edit: wow, beat by 7 seconds. sdfjhaklf.
    Last edited by tm8992 (2008-03-26 00:56:48)

  • Password protect zip files-Terminal help

    Hi. running OS 10.7.4 on my MacBook Pro. I want to password protect a zip file (FPTGH.zip) to send to both PC and Mac users. I created the zip file using the finder. That worked like a champ. The file is on my desktop. I opened Terminal and entered zip -e, my zip file name.zip, entered the password (correctly) twice, and I repeatedly get the following message.
    scm's MacBook-Pro:~ scm$ zip -e FPTGH.zip
    Enter password:
    Verify password:
    zip error: Nothing to do! (FPTGH.zip)
    scms-MacBook-Pro:~ scm$
    Then I tried creating the zip from the original file, and I get the same message:
    scm's-MacBook-Pro:~ scm$ zip -e FPTGH.txt
    Enter password:
    Verify password:
    zip error: Nothing to do! (FPTGH.txt)
    scms-MacBook-Pro:~ scmorgan$
    WHAT am I doing wrong?
    Stumped in Costa Rica. SC Morgan

    Linc, I do have a file named FPTGH.txt on my desktop. I highlight it (although that shouldn't make an difference) and run the script in Terminal and continue to get the "zip error" mesage.
    I've tried FPTGH FPTGH; FPTGH FPTGH.txt; and FPTGH.txt FPTGH.txt all with the error responses. When I try matching file names I get this:
    sarah-morgans-MacBook-Pro:~ scmorgan$ zip -e FPTGH.txt FPTGH.txt
    Enter password:
    Verify password:
    zip error: Invalid command arguments (password verification failed)
    sarah-morgans-MacBook-Pro:~ scmorgan$
    When I try use mismatched file names I get this:
    sarah-morgans-MacBook-Pro:~ scmorgan$ zip -e FPTGH FPTGH.txt
    Enter password:
    Verify password:
              zip warning: name not matched: FPTGH.txt
    zip error: Nothing to do! (FPTGH.zip)
    sarah-morgans-MacBook-Pro:~ scmorgan$

  • Privileges problems, terminal help??

    I have several users on the same computer, each had their own library in itunes. This meant lots of copies of music and so lots of waster harddrive space. A little while ago i managed to move all the music to the shared folder and linked the libraries. Everything went smoothley, or so i thought. When trying to accesss some of the music from some of the accounts, it says i do not have sufficent privileges. Narrowed down the problem to who owns the folder. Is there anyway i can quickly alter all the files contained within the iTunes music folder. I set up the correct privileges on the main iTunes music folder and selected to apply to all enclosed items, however it says i do not have sufficent privileges for that. This i worked out was because some items have become locked and no one can unlock them.
    Please help
    Richard

    I would try using BatChmod while logged in under the appropriate account and setting ownership and permissions on the folder ~/username/Music/iTunes as follows:
    R-W-X, R-X, R-X
    To do this, launch BatChmod and click the File button. Then navigate to the folder iTunes and click the Open button. Make sure the owner is set to the correct user name, and group as well. Check the Apply ownership and permissions as well as the Unlock checkboxes, then click the Apply button. You may need to reboot after this to verify that things are working properly.

  • Terminal help plz

    i got a new computer today and i want to take a look at the entries that i have made to the terminal in the past on my old computer.
    in other words, is there a way to recall input that was put into the terminal in the past?

    Depending on what particular information you're looking to retrieve from Terminal.app on your previous Mac OS X system...
    Here are the Terminal plist settings, converted back to a readable XML file, and the defaults version:
    plutil -convert xml1 -o ~/x.x /users/{user}/library/preferences/com.apple.Terminal.plist
    or via the defaults command...
    defaults read com.apple.Terminal
    For as much of the bash shell command history as is available and saved, that's here:
    cat ~/.bash_history
    For the login profile and other hidden login files...
    ls -al
    cat ~/.profile

  • Terminal help.... Cant type in Terminal

    I open terminal and get this message and cant do anything with it. I dont use terminal but I want to turn off the genre browsing pane in itunes and terminal was the only way to go. heres the message i get.
    and i cant type anything after this:
    login: illegal option -- S
    usage: login [-pq] [-h hostname] [username]
    login -f [-lpq] [-h hostname] [username [prog [arg ...]]]
    [Process completed]

    Post Unix and Terminal queries to the Unix forum under OS X Technologies.

Maybe you are looking for

  • Org.xml.sax.SAXException

    Hi all, I am trying to invoke a method from my BPEL console of my webservice.I am passing inputHeader variables(For passing WS-Addressing) related information.On invoking my web service,the following error is thrown <remoteFault> <part name="code" >

  • Will Onkyo 1080p AR resolve the HDMI "handshake​" problems?

    Question, I'm plan to upgrade my audio receiver and thinking of going to a 1080p upconversion such as an Onkyo SR806.  This requires a set up of the HD DVR (Motorola 6416-2) with HDMI to the receiver and HDMI to the Samsung LCD.  Will that cure the "

  • Key figure description not show in BEx and WAD sometimes

    Hi experts! I have a big problem. Sometimes we have the effect that a report shows no key figures. I mean I see the numbers but no key figure description is shown. Example (correct) Country |    Hierarchy   |        Banking      |         ATM       |

  • Reorder Page Numbers

    Hey everyone, First, I am one that is absolutely in love with CS4. The multiple pages are awesome and wonder how I got along with that feature until now. I do have a question about page numbering. As I duplicate and move around each page of a project

  • Facebook/Flickr Uploading Messed up pictures

    I have been using iPhoto with Facebook and Flickr before, but I seem to be having problems. My albums have 64 pictures, but not all upload. Sometimes on Facebook only 11 show up. I tried to restart, delete the .plist, quit, log out and log in, no luc