Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Mac Terminal
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="mac57" data-source="post: 335007" data-attributes="member: 17052"><p>Assuming gcc is installed, the simplest way may be to compose a make file and use the make utility.</p><p></p><p>Here is an example. Assume you have file program.c that you want to compile and link so that the result is the executable "program".</p><p></p><p>In the same directory as program.c, place a file called Makefile - the "M" should be uppercase. Create this file with your favorite editor and put the following lines in it:</p><p></p><p>[CODE]# Make file to create the "program" executable</p><p></p><p>program : program.c</p><p> cc -o program program.c</p><p>[/CODE]</p><p></p><p>Now, to compile and link in one step, just issue the command:</p><p></p><p>[CODE]make</p><p>[/CODE]</p><p>That's it! Much simpler than manually typing in the whole "cc" command. </p><p></p><p>BTW, cc is normally aliased to gcc, hence the use of the "cc" command vs. the "gcc" command. Using "cc" instead makes the Makefile more portable, since many *nix systems have a native "cc" and don't need gcc.</p></blockquote><p></p>
[QUOTE="mac57, post: 335007, member: 17052"] Assuming gcc is installed, the simplest way may be to compose a make file and use the make utility. Here is an example. Assume you have file program.c that you want to compile and link so that the result is the executable "program". In the same directory as program.c, place a file called Makefile - the "M" should be uppercase. Create this file with your favorite editor and put the following lines in it: [CODE]# Make file to create the "program" executable program : program.c cc -o program program.c [/CODE] Now, to compile and link in one step, just issue the command: [CODE]make [/CODE] That's it! Much simpler than manually typing in the whole "cc" command. BTW, cc is normally aliased to gcc, hence the use of the "cc" command vs. the "gcc" command. Using "cc" instead makes the Makefile more portable, since many *nix systems have a native "cc" and don't need gcc. [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Mac Terminal
Top