Answer the question
In order to leave comments, you need to log in
Hello, world does not compile to C on MacBook (VS Code). What to do?
At the university, we were asked to write a program in the C language. Well, I decided first, in order to understand the language itself at least a little, to write a simple Hello, world, but nothing has been working for the second day. Let's start over:
I downloaded VS Code on a MacBook. Development environment - yes.
Next, I created a folder that I called HW Proj and through VS Code I opened a file in it that I called hello.c
By the way, I downloaded the C / C ++ extension that VS Code offered me, and also downloaded Xcode and the extension to it , which I downloaded when I first opened Visual Studio 2019 (I also downloaded it and he offered me this extension, I downloaded it)
Then I opened this folder (Open Folder) in VS Code and opened this file in it. Wrote this code:
#include <stdio.h>
int main ()
{
printf("Hello, world!\n");
return 0;
}
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: x86_64-apple-darwin20.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
[email protected] HW Proj % cd ~
make***: No rule to make target 'hello'. Stop.
You have not agreed to the Xcode license agreements. You must agree to both license agreements below in order to use Xcode.
Press the 'return' key to view the license agreements at '/Applications/Xcode.app/Contents/Resources/English.lproj/License.rtf'
Xcode and Apple SDKs Agreement
By typing 'agree' you are agreeing to the terms of the software license agreements. Type 'print' to print them or anything else to cancel, [agree, print, cancel]
You can view the license agreements in Xcode's About Box, or at /Applications/Xcode.app/Contents/Resources/English.lproj/License.rtf
[email protected] ~ % agree
zsh: command not found: agree
[email protected] ~ % make hello
make: *** No rule to make target `hello'. Stop.
[email protected] ~ %
#include <stdio.h>
int main ()
{
printf("Hello, world!\n");
return 0;
}
[email protected] HW Proj % cd ~/Desktop/HW\ Proj
[email protected] HW Proj % make hello
cc hello.c -o hello
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [hello] Error 1
[email protected] HW Proj %
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question