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
VSC not working on MacOS
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="Raz0rEdge" data-source="post: 1841793" data-attributes="member: 110816"><p>A couple of things. You are writing a C program and should be using 'gcc' to compile it. 'g++' is used for C++ development.</p><p></p><p>My version of your Hello World application is:</p><p>[CODE]</p><p>#include <stdio.h></p><p></p><p></p><p>int main(void) {</p><p> printf("Hello World\n");</p><p> return 0;</p><p>}</p><p>[/CODE]</p><p></p><p>I compile with</p><p>[CODE]</p><p>gcc -o hello hello.c</p><p>[/CODE]</p><p></p><p>Not providing the '-o' option means you get <strong>a.out</strong> which can be confusing. <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" /></p><p></p><p>Now, I did use 'g++' to compile my code and beyond that (correct) warning, it did compile and run.</p><p></p><p>The fact that you are getting the other errors means that you don't have the command line build tools install, ensure you do so with </p><p>[CODE]</p><p>xcode-select --install</p><p>[/CODE]</p><p></p><p>You should then have the C Library necessary to run your program.</p><p></p><p>You should also likely install Xcode which is an awesome IDE for for your development needs. You can write programs in C, C++ and Objective-C for macOS, iOS, WatchOS and so on in there.</p></blockquote><p></p>
[QUOTE="Raz0rEdge, post: 1841793, member: 110816"] A couple of things. You are writing a C program and should be using 'gcc' to compile it. 'g++' is used for C++ development. My version of your Hello World application is: [CODE] #include <stdio.h> int main(void) { printf("Hello World\n"); return 0; } [/CODE] I compile with [CODE] gcc -o hello hello.c [/CODE] Not providing the '-o' option means you get [B]a.out[/B] which can be confusing. :) Now, I did use 'g++' to compile my code and beyond that (correct) warning, it did compile and run. The fact that you are getting the other errors means that you don't have the command line build tools install, ensure you do so with [CODE] xcode-select --install [/CODE] You should then have the C Library necessary to run your program. You should also likely install Xcode which is an awesome IDE for for your development needs. You can write programs in C, C++ and Objective-C for macOS, iOS, WatchOS and so on in there. [/QUOTE]
Verification
Name this item. 🍎
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
VSC not working on MacOS
Top