Lazy Ren
Lazy Ren

Reputation: 1

Taking first step for learning C lang. with MAC

Before moving on to question, I'm 100% newbie to programming and I'm on my own. So please answer my question even though you think it seems very silly.

Somehow I manage to install command line tools successfully:

LazyRen:~ LazyRen$ xcode-select -p
/Applications/Xcode.app/Contents/Developer
LazyRen:~ LazyRen$ xcode-select --install
xcode-select: note: install requested for command line developer tools
LazyRen:~ LazyRen$ gcc
clang: error: no input files

But the problem is when I tried to build the most basic codes with ST3 it gives me

clang: error: no input files
[Finished in 0.0s with exit code 1]
[cmd: ['gcc', 'Hello C World!', '-o', 'Hello C World!']]
[dir: /Users/LazyRen/Library/Application Support/Sublime Text 3/Packages/User]
[path: /usr/bin:/bin:/usr/sbin:/sbin]

This. I just have no idea what kind of input file is needed. Any hints?

Upvotes: 0

Views: 607

Answers (1)

CRD
CRD

Reputation: 53010

You appear to be lost inside ST3. As you have Xcode why not use it instead? To run a command line "Hello World" C program do the following:

  1. Open Xcode
  2. Select File > New > Project...
  3. On the left side select Application under OS X
  4. On the right select Command Line Tool
  5. Press Next
  6. Fill the 3 text fields with "hello" "LazyRen" & "com.lazyren" - these at not important in this situation, but the Next button won't be enabled till you fill them in.
  7. In the Type menu select C
  8. Press Next
  9. In the standard save dialog locate the folder you wish to store your code in and then press Create
  10. Project will now open in Xcode, select main.c on the left. On doing that the large editing area will show the starting template - which just happens to be "Hello World!"
  11. Select Product > Run - you've run your first command line C program. Output will appear in a small window.

Now continue with your C textbook. Also look at the Xcode documentation. In the latter you will find out how to locate the code you just compiled on the disc to you can run it from Terminal if you wish.

HTH

Upvotes: 1

Related Questions