I have searched and I have received the same answer but I believe mine is different
I have Xcode (4.3.2) installed on my mac and when I try to compile my .cpp file it says "command not found" Any suggestions?
How I try to compile;
g++ -o program code.cpp
You need to install the "Command-Line Tools" package through the XCode "Downloads" preferences tab.
open Xcode >> Preferences... >> Downloads and download command line tools
I use
make code
and it finds a compiler, compiles code.cpp and leaves the output in code. And it tells me the name of the compiler... (it is g++).
If you type "which g++" do you find an old alias?
Do you have /usr/bin in your path?
If you do, and /usr/bin/g++ isn't found, check that you've downloaded not only Xcode but the command line utilities that are now a separate download on the developer page.
Related
I'm in the process of installing XCode Command Line Tools onto OSX 10.9 Mavericks
I did a successful install XCode:
$ xcode-select -p
/Library/Developer/CommandLineTools
However when I type in either $ clang or $ gcc it returns:
clang: error: no input files
If you just type the command without any input files, then as commented, the compiler reports an accurate error message.
But if you have an existing project, then you can see that same "clang: error: no input files" message when:
you move your folder/files after making the project
one of your files isn't recognized by the XCode project
your project pre-compile header settings is wrong (wrong prefix):
In Xcode "Build settings" reviews the value for "Prefix header".
It seems to me that you have it set to "MySecondTabbApp/MySecondTabbApp-Prefix.pch" and it should be just "MySecondTabbApp-Prefix.pch"
The OP user2925321 comments:
The error was that I was running through steps to configure ruby and was directed to instructions on another page that just stated to check for $ gcc instead of $ gcc --version.
Obviously new to coding, trying to learn more.
Try gcc -v.
I am on a Mac (Mavericks) and that worked for me. It will tell you which version you are using (and you will know it is installed).
I faced the same issue. Type in xcode-select --install. It will work.
Another possibility: double check how the file in question is added to the xcode project. In my case, the file was set to "relative to group" instead of "relative to this project" and it was causing this error.
just type gcc -v which will spit an output specifying the prefix flag with which gcc was installed and the LLVM version as well. Specifying gcc on the command line without an option will report the issue you say it is reporting because its not able to find a file to compile using gcc.
I was seeing this error while setting up a React Native project. Here is what worked for me.
sudo xcode-select --switch /Applications/Xcode.app
I have a xcode project that was created for osx snow leopard. All it was required to be built was to run
xcodebuild
from the command prompt. I am now trying to build the same project on OS X 10.7 and the following error happens when I run the same command
/Users/repo/trunk/main.c:31:10: fatal error: 'stdlib.h' file not found
What exactly is going on? I tried to follow the instructions from this question but stdlib.h is still missing.
How can I fix this problem?
Likely you are getting bit by the repackaging of everything inside /Applications/Xcode.app starting with Xcode 4.3. In Unix-like installations stdlib.h usually lives in /usr/include and your project likely expects it to be there as it was pre-Xcode 4.3. You can fix this by installing the command line tools, which includes the tools and the associated headers and libraries in their standard location.
The easiest way to install the command line tools is from inside Xcode. In the Xcode Preferences select the "Downloads" pane and then the "Components" tab. Push the "Install" button next to "Command Line Tools".
You need to run xcode-select to tell xcodebuild and xcrun which Xcode you want to use.
See this manpage.
I am at a place where I don't have the installation CD or the bandwidth to do a full Xcode install (It would take well over a day) to get gcc. However I did install xcode and I notice in Developer/Xcodefiles/usr/bin/ that there is gcc. When I click on it, a terminal opens up and exits complaining no input file. Is there any way I can salvage this? man gcc says no manual entry for gcc.Thanks in advance for the help.
If you want only gcc on OS X go here: https://github.com/kennethreitz/osx-gcc-installer
I've installed XCode v3.1.3 and am having difficulties using the rumored GCC that is installed along with it. -- I'm certainly able to use the XCode IDE to compile my programs but would like the flexibility of also using the command line...
Where's GCC?
Look in /Developer/usr/bin
The most likely explanation is that when you installed the Developer tools you unchecked "UNIX Development Support", so the command line tools were never installed. Delete your /Developer/ directory and do a clean install of the tools; make sure to select "configure" during the installation process and ensure that the appropriate items are checked.
In /usr/bin you should find gcc-4.0 and gcc-4.2 and then there will be a symbolic link gcc which points to one of these (usually gcc-4.2).
As always, you can find out where any available command in your PATH is located using which, e.g.
$ which gcc
I have installed Xcode from the Tool cd, I thought that would let me use gcc from the command line but I can't find it.
What am I missing
EDIT
When I wrote I can't find it I meant "I look for it using which gcc"
If gcc would have been in the PATH in first place, which would have find it.
Since gcc is not in the PATH ( that's what brought me here in first place ) which won't find it!
I think that was obvious but I'm making the note here because it wasn't
As of version 4.3.1, XCode is now an application and the command line tools are now available through the Preferences (this is documented in the App Store for XCode under 'What's New in Version 4.3.1' if you click 'More...'). After installing XCode, open it, open the Preferences and click on the Download tab. Click on 'install' for the 'Command Line Tools' and then sign in with your computer's password. The code will then be downloaded and installed.
You didn't check the box that says "UNIX Development Support"[1] (or possibly you unchecked it; I can't remember if it's on by default or not) when you did the install, so it didn't install the necessary symlinks and drivers in /usr/bin/.
Reinstall, and make sure to read the descriptions of the configuration options and select the ones that you need.
1: "Optional content to allow command-line development from the boot volume. Installs a duplicate of the GCC compiler and command line tools blah blah blah..."
Something went wrong with your install.
gcc is installed under /usr/bin with a symlink to gcc-4.2:
cd diciu$ pkgutil --file-info /usr/bin/gcc-4.2
volume: /
path: /usr/bin/gcc-4.2
pkgid: com.apple.pkg.gcc4.2Leo
pkg-version: 4.2.0.9000000000.1.1249367152
[..]
pkgid: com.apple.pkg.Xcode3.2.1Update
pkg-version: 1.0.1.1249367152
[..]
pkgid: com.apple.pkg.Xcode3.2.1UpdateUNIXDevSupport
pkg-version: 1.0.1.1249367152
[..]
On my Mac $ which gcc displays /usr/bin/gcc.
Xcode 4.3+ you need to install 'Command Line Tools for Xcode' found here: https://developer.apple.com/downloads
Is it possible that rather than not having gcc installed, your $PATH variable is messed up? first check if gcc is in /usr/bin manually. Then echo $PATH...
The same thing happened to me. It worked for a while and then went away. Reinstall and it will be fixed.
You might want to download Xcode from Apple while you are at it. Almost guaranteed to be fresher / more up-to-date since Xcode is rapidly updated. Current Xcode is 3.2.1.10. You need an Apple ID to download, but that also gives you access to the development site. All free... .
It is 1/6/2014. Current Xcode is 5.0.1
It is 2016 -- Current Xcode is 8.0. I think this question should be closed now.
Yes, try to install 'command line tools' by clicking Preferences-Downloads-command line tools.