Cannot find stdio.h - macos

I am using macOS.
I am trying to build the code of mozilla-central.
While running the command ./mach build, the build fails at the compile step. Here are the relevant stack traces:
stack backtrace:
0:20.24 0: 0x10436b5ff - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::hed04c7a1477ef1e3
0:20.24 1: 0x10434499d - std::sys_common::backtrace::print::h336400f22676933f
0:20.24 2: 0x104373bd3 - std::panicking::default_hook::{{closure}}::h0d6700a02d682978
0:20.24 3: 0x10437395c - std::panicking::default_hook::h90363c6d6ac04260
0:20.24 4: 0x1043742fb - std::panicking::rust_panic_with_hook::h81c4f3add25e6667
0:20.24 5: 0x1043740ce - std::panicking::continue_panic_fmt::hfa057b7c1de88179
0:20.24 6: 0x104374020 - std::panicking::begin_panic_fmt::hd1123702300ea9f2
0:20.24 7: 0x1035f4e6d - build_script_build::build_gecko::bindings::write_binding_file::h2d9a397b93e6a614
0:20.24 8: 0x1035f651c - build_script_build::build_gecko::bindings::generate_bindings::ha066bc11b076e01d
0:20.24 9: 0x1043808fe - __rust_maybe_catch_panic
0:20.24 10: 0x1035eea9f - std::panicking::try::hcbd901ede6e8004c
0:20.32 11: 0x1035e335c - <F as alloc::boxed::FnBox<A>>::call_box::h638a7c5eb8c94414
0:20.33 12: 0x104373037 - std::sys_common::thread::start_thread::h78b1dd404be976ad
0:20.33 13: 0x1043436c8 - std::sys::unix::thread::Thread::new::thread_start::h27c6becca8cf44e0
0:20.33 14: 0x7fff636208cc - _pthread_body
0:20.33 15: 0x7fff6362083e - _pthread_start
0:20.33 /usr/local/Cellar/llvm/6.0.1/include/c++/v1/stdio.h:108:15: fatal error: 'stdio.h' file not found
0:20.33 /usr/local/Cellar/llvm/6.0.1/include/c++/v1/stdio.h:108:15: fatal error: 'stdio.h' file not found, err: true
0:20.37 thread '<unnamed>' panicked at 'Failed to generate bindings
According to me, the root cause is:
/usr/local/Cellar/llvm/6.0.1/include/c++/v1/stdio.h:108:15: fatal error: 'stdio.h' file not found, err: true
The solution listed online was to install xcode command line tools using:
xcode-select --install
I have already done this.

Try setting SDKROOT explicitly to the system SDK:
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
Doing it avoids the need for creating symlinks in /usr.
This error seem recurrent, for example, if you installed another compiler (e.g. gcc from brew). Setting SDKROOT became so common that it might be a good idea to add it to ~/.bash_profile.

The root reason is due to a missing /usr/include directory.
Installing command-line tools (xcode-select --install), sometimes, will not automatically add it.
The Link shows the correct way:
After installing command-line tools
Install the package at:
# run this in Terminal
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
After that,
you should have a directory /usr/include with header files

I had the same problem for compiling R packages, and running xcode-select --install and macOS_SDK_headers_for_macOS_10.14.pkg did not solve the problem.
I discovered that there seems to be some confusion from Apples side between macOS 10.14 and 10.15, since I'm running Mojave (10.14) with the latest xcode 11.0 (11A420a), and when clang compiles it looks for the MacOSX10.14.sdk sysroot directory in
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
but there only MacOSX10.15.sdk is present (along with other stuff). I fixed this with
pushd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
sudo ln -s MacOSX.sdk MacOSX10.14.sdk
popd
Now I can install packages in RStudio again.

This is a comment to Rick Li. It’s too long to fit into comment area.
The solution provided by Rick Li isn’t necessary the correct way. It’s only the easiest way. According to Xcode 10 release note:
…If you are the maintainer of such software, we encourage you to update your project to work with the SDK or file a bug report for issues that are preventing you from doing so. As a workaround, an extra package is provided which will install the headers to the base system. In a future release, this package will no longer be provided. …
So the right way is to contact Mozilla team that their application won’t build without hack. It will break eventually.
If you don’t take this seriously, it would bite you in future. I still recall that Apple deprecated 32-bit application on macOS 10.13 (High Sierra). Now they formally disabled it in macOS 10.15 (Catalina) and I hear about people crying everywhere. Be responsible of your choice.

I had the same problem. Tried to install the command-line tools via xcode-select --install but it didn't worked out for me.
After more research i found out that you can download the command-line tools on Apples official developer support site (Link)
Search for command and download first suggestion.
Run the .dmg file and see if works.
Worked out great for me!

I had the same problem (suddenly) compiling my own project - not finding <stdio.h> and <wchar.h>.
Running xcode-select --install said
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
The following steps worked for me:
Open Xcode once and allow it installing necessary components
Remove the CMake cache files and retry cmake and build
I'm on macOS Big Sur 11.2.3 with Xcode version 12.5.

Add -isysroot with needed MaсOSX version
It work for me: MacOS Big Sure 11.4 & XCode 12.5.1
Know latest MacOS SDK version path by command:
xcrun --sdk macosx --show-sdk-path
Add path result to -isysroot:
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk
UPD: if solution above did not help, try put -I to include from MacOS SDK
-I$(MACOSSDK)/usr/include\
-I$(MACOSSDK)/usr/include/c++\
-I$(MACOSSDK)/usr/include/c++/v1\
-I$(MACOSSDK)/usr/include/c++/v1/ext\
-Wnonportable-include-path

Command Line Tools Path Setting
I saw that "Command Line Tools" is not set in the xcode settings, as shown in the figure, click to select the Xcode path, and then compile, there is no such error.

Related

Issue with linker for Mac OS

I have recently started using ada for a lab in my systems programming class and I can say it is really interesting.
I tried most of it at the computers labs for testing and I decided to install the compiler and its linking tools in a MacBook.
Altough the installation is done and there seems to be no problem, when I tried to print the classic hello world program I am getting this message:
gprbuild greet.adb
using project file /Users/xyderos/opt/GNAT/2020/share/gpr/_default.gpr
Bind
[gprbind] greet.bexch
[Ada] greet.ali
Link
[link] greet.adb
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
gprbuild: link of greet.adb failed
gprbuild: failed command was: /users/name/opt/gnat/2020/bin/gcc greet.o b__greet.o - L/Users/name/ada/ -L/Users/name/ada// -L/users/name/opt/gnat/2020/lib/gcc/x86_64-apple-darwin17.7.0/8.4.1/adalib/ /users/name/opt/gnat/2020/lib/gcc/x86_64-apple-darwin17.7.0/8.4.1/adalib/libgnat.a -Wl,-rpath,#executable_path/ -Wl,-rpath,#executable_path/..//opt/gnat/2020/lib/gcc/x86_64-apple-darwin17.7.0/8.4.1/adalib -o greet
I am getting really confused about the lSystem library.
It seems that the library doesn't exist on Mac(maybe I need to install Xcode?).
Does anyone have a clue about that issue or is there a probably better way to install it via brew?
Thanks a lot in advance!
On my MacOS 10.14, the following worked for me, without having to download the massive blob that is Xcode, which I had neither the bandwidth nor the diskspace for. I don't know if this still works on MacOS 10.15 (not planning to upgrade).
Most of this info was from a blog post by Simon Wright: https://forward-in-code.blogspot.com/2019/06/macos-software-development-kit-changes.html
You only need the Xcode command line tools only (not Xcode): xcode-select --install
Now unpack the included headers: sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
And tell GNAT where to find them: mv ce2109-specs /usr/local/opt/GNAT/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/specs
The ce2109-specs file is from the blog post above. This did the job for me and GNAT can now link working binaries on MacOS 10.14.
If you're on 10.15 and it doesn't work (because there's no more Xcode command line tools or they're missing the headers package), you will unfortunately have to install Xcode as per the GNAT Readme.

Xcode install on OSX 10.9 - clang: error: no input files

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

How to build OpenCASCADE on MAC (Mountain Lion)

I am trying to build OpenCASCADE on Mac, but I am not having any luck.
I downloaded it from Github in tar.gz, but I am really new to Mac and I am stuck.
Can anybody explain what should be my next step?
(I found some terminal commands what I should use, but I am not familiar with them. So if it is the right way to build OpenCASCADE on Mac please write down the terminal commands with details. Thank you!)
EDIT:
I understood the command line commands now from the link below. I understood it before too, but I was mistaken, because my main problem was, that I didn't had gcc installed (XCode does not installs gcc automatically...). So anyways, now finally I can run the cmake command. It starts but it ends with this:
CMake Error at /Applications/CMake
2.8-9.app/Contents/share/cmake-2.8/Modules/FindX11.cmake:420 (MESSAGE): Could not find X11 Call Stack (most recent call first):
CMakeLists.txt:313 (FIND_PACKAGE)
Anybody have any idea what to do? I tryed to search this too here, and google...and I found some "solutions" but those didn't work for me.
EDIT EDIT:
The solution for the last edit is that Mountain Lion doesn't install X11. So open up an app that uses X11 or Xquartz and it will install automatically.
Unfortunetly it still doesn't work. My next error message is the following after the make command in terminal:
In file included from
/Users/davidbirkas/Documents/tpaviot-oce-6c9a06a/src/AlienImage/AlienImage_X11XWDAlienData.cxx:14:
/Users/davidbirkas/Documents/tpaviot-oce-6c9a06a/inc/Aspect_XWD.hxx:5:12:
fatal error:
'X11/XWDFile.h' file not found
# include
^ 1 error generated. make[2]: * [adm/cmake/TKService/CMakeFiles/TKService.dir/_/_/__/src/AlienImage/AlienImage_X11XWDAlienData.cxx.o]
Error 1 make1:
[adm/cmake/TKService/CMakeFiles/TKService.dir/all] Error 2 make: **
[all] Error 2
Any ideas how to fix this?
Ensure that, together with XCode, you also install the X11 support from Apple's Devtools. Your error message is indicating that it is missing.
FWIW, I have written a blog post about OCC and PythonOCC on Mac some time ago. Maybe you'll find some detailed info there.
http://cad-3d.blogspot.com/2011/10/pythonocc-open-source-interactive-cad.html
In this post, I still talk about using the binary installer, but recent updates to the OCE edition compile usually without problems out-of-the-box, also on OSX (that is NOT the case with the official OpenCASCADE release).
I spent a little time on this and I think I have it. Here is what I did step by step:
Preparation phase:
Installing Xcode (with command line tools) = Apple developer site
// If Xcode doesn't install gcc, than you can still download it from the developer site as Command Line Tools for Xcode.
Installing Cmake (with command line tools) = Google
// You can download it from the official site with a .dmg/.pkg file extension. Easy install.
X11 under Mountain Lion "changed" to Xquartz. Probably it is not installed by default, but it is easy to check it. Just go to the folder "Application" and start the X11 app. If X11/Xquartz is not installed than it will install automatically!
Installing FTGL = MacPorts = Google
// Download MacPorts from their official site, install it with the installer, than write this to the terminal:
sudo port install ftgl
Download OCE and extract it (.OCE-0.9.0.tar.gz file) = https://github.com/tpaviot/oce/wiki/Download
Installing phase:
I. Open Terminal.
II. Run this command
// This will set the proper PATH.
ln -s /opt/X11/include/X11 /usr/local/include/X11
III. Than from the Terminal go to the directory where you extracted the OCE file (the original extracted file name should be: tpaviot-oce-6c9a06a).
IV. Than write these commands:
// You make a build directory to the extracted OCE folder.
mkdir build
cd build
V. After this you give out the cmake command:
cmake -DOCE_INSTALL_PREFIX:PATH=$HOME/OCE \
-DOCE_WITH_FREEIMAGE:BOOL=ON \
-DOCE_WITH_GL2PS:BOOL=ON \
-DOCE_DRAW:BOOL=ON \
..
VI. And at the end the make commands:
make
make install/strip
If you did everything exactly like this, than it should work!
Give OCE a try. Compiling for osx is a walk in the park

xcodebuild and C standard library

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.

Where is gcc on OSX? I have installed Xcode already

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.

Resources