After upgrading to Lion, and upgrading Xcode, make can't seem to locate headers and libs. I looked in /usr/include. The only thing in there was 'parallels-server'. So, I renamed /usr/include to /usr/include.old, and made a symlink to:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/
This is pretty evil. But, make can now find headers. Still can't locate libs (e.g., lcrt1.10.6.o).
What is the correct way to solve both the include and lib problems?
Thanks!
After downloading Xcode 4 from the App Store, try running "/Applications/Install Xcode.app".
From me, just downloading the Xcode Command line tools did the trick. (For that, of course, I had first to install Xcode itself, which I installed trough App Store.
Start Xcode
Open Xcode→Preferences...
Select the Downloads tab
Install the Command line tools
That installs a few packages, see /var/db/receipts. The package that contains /usr/include is com.apple.pkg.DevSDKLeo.
I don't think xcode-select is needed, but I had run that command before I downloaded the Command line tools, so I don't know for sure.
To get Xcode to populate the /usr/include directory, run the following command:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/
You may need to install the Xcode Command Line Tools within Xcode for this to work. Open the Preferences menu, then under Downloads install Command Line Tools.
The above answer by njamesp also addresses the following error:
configure: error: C compiler cannot create executables
I received this error when trying to compile code on my 10.7 system after setting it up from a 10.5 time machine, so I assume the wrong version of xcode was installed on my system.
Related
I'm on Mac OS X Yosemite 10.10.2. As far as I know, wx-widgets were preinstalled on older versions on OS X (probably that's why google search doesn't help), but that's not the case anymore. I need to get started on a C++ project using wx-widgets, using any IDE (Eclipse, Codelite, or whatever is best). However, I simply cannot get wx-widgets to work. After a workaround I was able to compile on my machine wxWidgets-3.0.2. I called from terminal make and make install, but the libraries seem to not be correctly installed. Indeed, if I create a project on Codelite I get many "wx-config: Command not found" errors. Can someone help me to get me started on installing the libraries and creating a simple project that includes wx-widgets?
I use homebrew which is installed by copying and pasting one line from the homebrew website.
Then, the installation of wxWidgets is simplicity itself with:
brew install wxmac
Any problems, you just call the doctor with
brew doctor
Now you have a proper package manager you can install ImageMagick, GNU Parallel, GNU awk, Oxygen, webkit2html, zeromq, tree, SDL, Redis, sqlitebrowser, pandoc, exiftool, ffmpeg, 7zip, awscli, etc...
You can then compile your wxWidgets programs with
g++ `wx-config --cxxflags` -o sample sample.cpp `wx-config --libs`
I can successfully compile and install wxWidgets on Yosemite with these commands:
- Get the latest sources of wxWidgets 3 from wxwidgets.org and unpack them.
- Move the unpacked directory someplace where you want to keep it.
- Open a terminal and change into the wxwidgets directory.
- Create two directories: build-release and build-debug (don't rename those!)
- Change into wxwidgets/build-release
- Run
../configure --with-osx_cocoa --disable-shared --with-opengl --enable-universal-binary=i386,x86_64 --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --with-macosx-version-min=10.6
- Run make, then sudo make install
- Change into wxwidgets/build-debug
- Run
../configure --enable-debug --with-osx_cocoa --with-opengl --enable-universal-binary=i386,x86_64 --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --with-macosx-version-min=10.6
- Run make, then sudo make install
Be aware that these instructions are for compiling against the Mac OS X 10.6 SDK, which I have at /Developer/SDKs/MacOSX10.6.sdk. You can try to omit the --with-macosx-sdk parameter altogether, which will compile using the latest SDK. Also ensure that you have Xcode and the command line developer tools installed.
These commands will install static libraries for the release build and shared libraries for the debug build. You can change this by supplying or omitting the --disable-shared parameter.
The instructions for building and installing wxWidgets are included in the distribution and can also be viewed online.
If your IDE doesn't find wx-config, you must not have the location where you installed it (/usr/local/bin) by default in your PATH. Add it there to fix this.
Like suggested by VZ, you must change your PATH.
But not the variable PATH in your environment Windows but the variable PATH in your C++ project. It's strange but maybe it's different.
Go into (for eclipse) :
C/C++Build->Environment->PATH (add the path of wx-config in the beginning).
Press : Apply, OK and build the project.
I think is strange that Eclipse don't update the PATH after rebooting the OS. Maybe we must add an option to Eclipse for building WxWidget and force Eclipse to update the PATH, but I don't know it.
This change work for me.
Eclipse / MinGW-MSYS / WxWidget 2.8
I am having a hard time finding clang-format and clang-format.py on my Mac OS 10.8.5 with Xcode 5 and its Command Line Tools. I tried find / -name "clang-format.py" without luck. Are they already here somewhere hiding, or how would I get this toolchain?
(I'm surprised it doesn't seem readily available since clang is Apple's compiler---in that Apple uses it.)
Seems like Apple doesn't ship clang-format with the Command Line Tools. Right now you have at least three options:
Using Homebrew (That's the way to go)
Using prebuild packages
Build it yourself
Homebrew
As user johnhaley81 pointed out, clang-format is now in homebrew:
clang-format is now on brew. brew install clang-format
Please consider upvoting his post if you find this answer useful.
Prebuild packages
Pre-build bundles are available at llvm.org. For Mac OSX, you need to download the darwin package.
Build instructions:
Here's an instruction on how to do this:
http://nacho4d-nacho4d.blogspot.de/2013/11/clang-format.html
And here's another one:
http://blog.hardcodes.de/articles/63/building-clang-format-and-friends-on-osx-mountain-lion
You can use brew now to install clang-format.
brew install clang-format
I know this is not a direct answer to the question but if you are just looking to format your code in Xcode. I just used this plug in.
https://github.com/travisjeffery/ClangFormat-Xcode
Specific versions of clang-format
As of november/2018, current clang-format formula on Homebrew points to version 8.0.0. Run clang-format --version to check yours.
If you need older versions of clang-format, consider following these steps:
Installing clang-format version 5 (5.0.2) with homebrew
Installing clang-format version 7 (7.0.0) with homebrew
In my case I installed clang-format with brew install and located here:
/usr/local/bin/clang-format
If you have the llvm toolchain already installed, you can find the clang-format.py file in /usr/local/opt/llvm/share/clang/clang-format.py without having to install a separate clang-format binary through Homebrew.
If you have installed clang-format via brew, the clang-format has been downloaded under
(Just use my MacOS12.3.1+XCode13.4+clang-format#5.0 with upgrade from macOS10.12.6+Xcode8+clang-format#5.0 as an example)
/usr/local/Cellar/clang-format#5/
with it's executable file clang-format under
/usr/local/Cellar/clang-format#5/5.0.2/bin/clang-format
with it's configuration file clang-format.py under
/usr/local/Cellar/clang-format#5/5.0.2/share/clang/clang-format.py
ALso,
the clang-format#5.0 will create soft link executable file clang-format under
/usr/local/bin/clang-format -> ../Cellar/clang-format#5/5.0.2/bin/clang-format
(that's why while I check where the clang-format is no matter using where clang-format or which clang-format or even whereis clang-format, that always shows /usr/local/bin/clang-format.)
(If you want to check where soft link /usr/local/bin/clang-format linked to?
Just use the command to check cd /usr/local/bin/ && pwd && ls -al | grep "clang-format", liking mine showing:)
/usr/local/bin/clang-format -> ../Cellar/clang-format#5/5.0.2/bin/clang-format
and the clang-format#5.0 soft link create configuration file clang-format.py under
/usr/local/share/clang/clang-format.py
the upstairs soft link linked to
/usr/local/Cellar/clang-format#5/5.0.2/share/clang/clang-format.py
Others,
somebody's download clang-format#3.8 maybe under
/usr/local/Cellar/clang-format
with executable file clang-formatunder
/usr/local/Cellar/clang-format/2019-01-18/bin/clang-format
with configuration file clang-format.py under
/usr/local/Cellar/clang-format/2019-01-18/share/clang/clang-format.py
withe the upstairs soft link clang-format.py under
/usr/share/clang/clang-format-3.8/clang-format.py
Update:
I solved the problem in the end by reinstalling command line tools, as shown in this link.
Sorry for the trouble!
Initial question
I have just upgraded to OSX Mavericks and I cannot make the compiler work anymore.
I've been using gcc48 from macports with vim/sb2 and everything was working just fine. Now any library that I include gives tons of errors. I am not very experienced and I do not know what to do, or what to search for. I just want it to work like before. Here is what is says when compiling a basic "hello world" program:
In file included from /opt/local/include/gcc48/c++/bits/postypes.h:40:0,
from /opt/local/include/gcc48/c++/iosfwd:40,
from /opt/local/include/gcc48/c++/ios:38,
from /opt/local/include/gcc48/c++/ostream:38,
from /opt/local/include/gcc48/c++/iostream:39,
from ceva.cpp:1:
/opt/local/include/gcc48/c++/cwchar:44:19: fatal error: wchar.h: No such file or directory
#include <wchar.h>
If you need any information, tell me and I will provide it to you. Thank you for your patience!
[Added 2019 - Mojave/Catalina] XCode 10 has removed the placement of headers in /usr/include, even with the command line tools. If you want headers, and you're on you should be able to install a transitional package, which is available on Mojave. This package is not present on the Catalina. The headers are within the SDK for the appropriate release.
XCode 5/Mavericks have changed the defaults for where headers are located.
On prior versions of Mac OS X / XCode you would have found headers in /usr/include.
When you built gcc on the older release it picked up the headers from that location, and looks for them there now when you try to build code.
The problem is that the files are not there; they're somewhere under /Applications/Xcode.app/Contents/Developer.
You could futz about with a spec file to get it working consistently again, but the sanest thing to do is rebuild gcc.
As has been mentioned as well, you can install the command line tools using xcode-select --install, which will reinstall the developer tools, including the headers in /usr/include.
I tend to reinstall things like gcc when I upgrade my operating system as I encounter other errors due to changes in the environment. This is just a habit I've formed. It may not be the best habit, but it's saved me pain on numerous occasions.
[added 2017] As an addendum, if you install the command line tools, then the headers will be placed in /usr/include as well. The command to install the command line tools is xcode-select --install - this will allow you to use most compilers without having to specify the location of the headers manually.
This is how I got it working on Mac osx Mavericks:
Open terminal
type --> xcode-select --install
A pop-up windows will apear asking you about install tools
choose install tools
wait install to finish
Here is a manual method for updating XCode on OS X Mavericks:
Go into the developers site http://developer.apple.com
Then go to Downloads for Apple developers and there is a command line tools installer for Mavericks — here's the link (but you'll need a developers account for the link to work) http://developer.apple.com/downloads/index.action?q=xcode
I'm using MacOs Sierra 10.12.4, got the same problem.
I solved it by using:
/usr/bin/gcc
For me the fix was to uninstall old broken gcc:
brew uninstall gcc#5
I noticed paths like /usr/local/Cellar/gcc#5 in build output, while gcc#8 was also installed and is the one that was supposed to be used.
When I try to compile a c++ program in my Mac terminal, I get the following error:
-bash: g++: command not found
but I believe I have all the files I need on my Mac to run the compiler. I have the Developer folder, which contains Xcode in Applications, g++ in the usr/bin folder, and a bunch of other folders.
How can I use these files to install the g++ compiler. Thank you!
Assuming you have the latest Xcode, go to Xcode Preferences, Downloads, and click on the Install button next to Command Line Tools. This should install and put everything into your PATH automatically.
houbysoft's answer above is correct, but the OP needs a little more detail.
The basic idea is that you need the "Command Line Tools" environment installed. But the name for that environment, and how you install it, has changed multiple times over the years. So, houbysoft's steps work for 4.3.3, but not for 3.2.6.
In the 3.2 era, the tools were called "UNIX Development". And, rather than being downloaded and installed from within Xcode, they came as part of the Xcode mpkg and were installed as part of the initial Xcode install. In most versions, there was a checkbox named "UNIX Development", usually checked by default, but in some versions it was a separate step. Looking at the "Xcode 3.2.6 and IOS SDK 4.3" disk image currently available from Apple, it's a checkbox. Anyway, that's the only officially-supported way to get them, but lots of other ways work… Here are your options:
Throw away Xcode 3.2.6 (just trash the whole /Developer) and install 4.3.3, then follow houbysoft's steps to get the Command Line Tools. Unless there's a good reason you can't use 4.3, this is almost certainly the best answer.
Throw away Xcode 3.2.6 and reinstall it, and this time make sure the "UNIX Development" checkbox is on.
Just re-run the 3.2.6 installer, and make sure the "UNIX Development" checkbox is on.
Log into developer.apple.com and look through the downloads for a package named "UNIX Development Tools", "Developer Tools CLI", "CLI Developer Environment", "Command Line Tools", or similar that corresponds to 3.2.6. There is such a package for most, but not all, versions of Xcode, and can be used to set up a command-line build environment either with or without Xcode.
Look at the invisible packages on the Xcode disk image. I don't remember whether you need just DeveloperToolsCLI.pkg, or that plus a few others, but a bit of trial and error or googling should get you there.
If everything is installed correctly, it sounds like all you need to do is get your "PATH" environment variable modified.
This closely related SuperUser question should provide the answers you need, at least if you're running under Snow Leopard. Here's another question about setting environment variables for Lion.
I installed Boost with homebrew(brew install boost) on my Mac running Lion with the purpose of extending python with an existing C++ program I have. Now I can't follow the starting guide because 1 - I don't have 'bjam' installed in my system and 2-I don't see the examples folder anywhere. My question is: how I am supposed to do the the c++-python linking with this homebrew installation without 'bjam'? is there some alternative method I should use or something I am missing here?
The right formula to install boost for linking c++ with python programs is:
brew install boost-build
as pointed out by senderle in the comments to my question. This installs bjam automatically.
For Windows, you go into $(BoostDir)\tools\build\v2\engine and run build.bat which automatically builds bjam (into the bin.ntx86 directory on windows). There is a build.sh file there too, but I've never used a Mac so I don't know if that will work for you. Otherwise, just do a Google search for a precompiled bjam executable for Mac OS X.
It should just be a case of downloading Boost then running "Bootstrap" followed by "Bjam".
Bootstrap should build you a Bjam executable in the Boost folder.