I am a beginner, trying to code C on a Mac. I am using Learn C the Hard way By Zed but when I tried running the C code on my Mac it would not run. I have installed Xcode from the mac Appstore but when I try to run my code using the command "make" or "gcc" the terminal responds command not found.
Am I doing something wrong?
I have tried searching for the solution but all of the ones I have found say just to install Xcode and do not give further instructions.
I am just hoping to find out how to test/run my code.
Thanks for the help in advance!
Install the Command line tools via xcode. You just go into preferences and then downloads.
XCode 4.3 Command Line Tools
If you still have troubles after updating xcode or installing command line tools try this install after:
https://github.com/kennethreitz/osx-gcc-installer
Good Luck!
Related
I followed the tutorial here from the Medium: https://medium.com/#GuruAtWork/setup-fastai-ubuntu-on-windows-10-44ca50b13a9
I was following it well until a MinGW was used for command lines. I am not sure how they went about doing this as the only way I could get nvcc to work is with sudo apt install nvidia-cuda-toolkit. However, this does not seem to complete the same thing as their tool kit is installed as if the exe was just run with Windows. However, that, of course, doesn't work with the Ubuntu. Let me know what you think, thank you.
AFAIK it's just not possible right now to do so from WSL. The link from Medium only sets it up for the Git bash prompt, which is not the same as WSL.
I should preface this by stating I'm working with Xcode on macOS Sierra 10.12.6.
I installed GDB with homebrew and it appeared to install fine until I tried to use it. In terminal it kept saying that it was not a valid command. (I'm new to C and was working with my professor. Even he was baffled when I tried to use it after downloading it in front of him). So later I tried to install it by creating the make file and still having problems. I then used homebrew again but to uninstall and reinstall, still having problems.
Now I'm at the point where I can't even run my C files when I use gcc to compile them. I simply get a statement that unable to open file. I've read someone suggest to sudo mv /usr/local /usr/_local and I'm notified that I don't have permission, even after entering in my password.
I've gotten every error when I try to remove all items belonging to gdb. I've gone as far as removing Xcode in hopes that I can do a fresh install of it all.
I'm at the point where I've begun looking into removing my macports entirely.
I'm looking for any advice into how I can try to start off from a clean slate. I need to use gdb on a project that is due and can't get this up and running. Please help talk me from a ledge!
EDIT:
I have used Sublime to create a simple Hello World file and it compiles and runs fine with gcc. So my project file has become corrupted somehow. At least I can calm down a bit. But I would still like to get this gdb issue figured out and install a fresh copy with everything old removed.
I'm working with Xcode on macOS Sierra 10.12.6
I need to use gdb on a project that is due and can't get this up and running
I don't know how to reinstall gdb on macOS, but be aware that gdb is broken on macOS Sierra as of now (at least debugging dynamic libraries), see Bug report.
So if you even get gdb correctly installed you can probably end up with nothing (gdb won't be able to debug what you want).
Try making your file executable using gcc -Wall -g $fileName.c -o $fileName. This will show all the errors that might exists. Secondly, if it doesn't work and you absolutely need to use gdb, using a VM of Linux(recommend Ubuntu if you're new to Linux or Mate) is a good alternative. You then have to just use sudo apt-get install gdb and even install gdb-dashboard git-hub gdb-dashboard if you want to do some serious debugging. That's the quickest fix that I can think of you are in a hurry. Btw good VMs are VirtualBox and Parallel Desktop(if you want to have access to your local files from the VM).
Whenever I try to compile my c program on mac it gives the following error. I am completely clueless about it.
'sys/cdefs.h' file not found
have you installed "Xcode Command Line Tools" ? just install it in your terminal.
sudo xcode-select --install
Install Xcode, if you haven't already.
Then, from Terminal do the following to avoid future similar (not necessary just for this, I don't think) issues in future:
xcode-select --install
This will automatically download and install the latest XCode Command Line Tools.
From Xcode 4.3, the Xcode is installed from Mac App Store. By default, there is no command line tools. Probably you have missed it. They can be installed using the Components tab of the Downloads preferences panel.
I'm not that experienced with C, but I've been happily hacking firmware on some hobby projects using WinAVR. I'm visually impaired so I prefer using make files and the command line, instead of a graphically confusing IDE.
Sometimes I want to thrash out an algorithm at the Windows console prompt, with a few printf statements to show me what's happening. But I don't want to install a native Windows variant of GCC and mess up my working WinAVR installation.
What's the best way to proceed?
i think http://www.cygwin.com/ would be a great choice.. you can install cygwin and then install gcc install cygwin. you can have all the unix tools if you want
I cannot seem to figure out how to use Eclipse CDT.
I am on Mac OS X, and am trying to print "Hello World" in C but I get an error:
Program "gcc" not found in PATH.
What can I do to use C in Eclipse?
I had the same problem. It may be because you don't have GCC compiler installed on your computer.
On OSX, you just have to open the Terminal and check which gcc. If it doesn't return a path, then install GCC from here.
Once installed, this command should return the path :
I just had to restart Eclipse and everything worked well then.
Have you installed XCode on your machine
update
I would suggest following this tutorial to install brew. You can skip the ruby part if you don't need it.
This is how i got rid of it.
Install the MinGW.
Select all files in the Basic Setup and select apply the changes.
Select new C++ Project You will be able to see "MinGW GCC" in the toolchain section select the same and create project.