I can't import simple c libraries - c

When I am trying to run cmake I get this error
fatal error: 'stdio.h' file not found
#include <stdio.h>
^~~~~~~~~
I am using mac and people recommended me to run this command
xcode-select --install
I get this in respond
command line tools are already installed, use "Software Update" in System Settings to install updates
Then I checked my software update, but everything is up-to-date which is MacOS 13.1 (22C65).

Related

VS Code C Error - Invalid Active Developer Path

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
This is the error I get in VS Code's terminal. There are error squiggles under the "#include <stdio.h>" line.
This is after I upgraded to Mac OS Monterey.
What is the reason for this error and what is the solution?
When upgrading your Mac OS, sometimes the code command-line tools stop working. This can be resolved by running this in the terminal:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
If you don't have Xcode installed you should do:
xcode-select --install
which will install the command-line tools without having Xcode.
The fix, luckily, is pretty straight forward. Install the Xcode toolkit! Even if you had it installed before, you might have to re-register it or update it to the latest version.
$ xcode-select --install
If that doesn’t work, force it to reset. You’ll need sudo access for this one.
$ sudo xcode-select --reset
trying to learn python :
I cant install python on my mac ,some error when installing , tried donwloding all version for mac , still same error :https://www.python.org/downloads/macos/
when debuggong in VS Code : manually-specify-an-interpreter
https://code.visualstudio.com/docs/python/environments#_manually-specify-an-interpreter
tried to install an interpreter , failed
checked installed version on my mac , only found a path in
xcrun: error: invalid active developer path, problem after zsh update for flutter
this worked out
xcode-select --install
This helps me fixing

Compiling through macOS Terminal, fatal error: stdio.h: No such file or directory

So was trying to compile a c file (via a makefile) and got the "fatal error: stdio.h: No such file or directory" . This compiles on just fine via cygwin and a remote linux box just not my mac (so the files are okay).
I have installed the mac command line tools as mentioned in this question. When I do gcc --version I am getting 5.3 but if i do brew info gcc i get 8.2. When I do a find through terminal I can the file, so not sure what is up.
If you run:
which gcc
you will get /usr/bin/gcc which is the compiler supplied by Apple as part of macOS.
Presumably, since you mention homebrew, you mean to use the compiler installed by homebrew. So, you need to look in /usr/local/bin and see what homebrew has installed:
ls -l /usr/local/bin/gcc*
lrwxr-xr-x 1 mark admin 29 17 Sep 10:53 /usr/local/bin/gcc-8 -> ../Cellar/gcc/8.2.0/bin/gcc-8
So, the answer to your question is:
firstly, you need to have /usr/local/bin at the start of your PATH, and
secondly, you need to use the following command to compile:
gcc-8 main.c -o main
try running following:
xcode-select --install
See:
GCC fatal error: stdio.h: No such file or directory
for details.
With Mojave and XCODE 10, the problem is that the "include" folder is no longer automatically included when you install the command line tools. Instead, you need to do an "open" on /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
That solved the identical problem for me, anyway.
I ran into this issue and this is how I resolved it.
softwareupdate --all --install --force
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
Basically developer framework is likely to be broken. But simply running xcode-select --install may not work because it will say the xcode developer tools are already installed (despite its broken status). So I had to completely wipe out any existing installation and install the developer framework again.
FYI if everything is installed correctly, the header files should be found at:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include

Installing glibtop on ubuntu

I'm new to ubuntu and i'm currently using it on windows 7 with vmware workstation.
I need to access the CPU usage with a C program on terminal, so i thought of using glibtop_get_cpu() function on glibtop library. I just wrote #include <glibtop.h> in my code and compiled it with "gcc" on terminal, and it said
fatal error: glibtop.h: No such file or directory
compilation terminated.
I tried to install the library using this:
sudo apt-get install liblib2.0-dev
but the terminal said:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package libglib2.0-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or is only available from another source
However the following packages replace it:
libglib2.0-0 libglib2.0-bin
E: Package 'libglib2.0-dev' has no installation candidate
any ideas about this?
You should install libgtop2-dev (sudo apt-get install libgtop2-dev).

GCC fatal error: stdio.h: No such file or directory

I'm trying to compile a program in C on OS X 10.9 with GCC 4.9 (experimental). For some reason, I'm getting the following error at compile time:
gcc: fatal error: stdio.h: No such file or directory
I then tried a simple Hello World program:
#include <stdio.h>
int main(int argc, const char *argv[])
{
printf("Hello, world!");
return 0;
}
Again, upon running gcc -o ~/hello ~/hello.c, I got the same error. I'm using an experimental version of gcc, but it seems implausible that there would be a release which generated errors upon importing stdio. What could be causing this issue, and how can it be fixed?
macOS
I had this problem too (encountered through Macports compilers). Previous versions of Xcode would let you install command line tools through xcode/Preferences, but xcode5 doesn't give a command line tools option in the GUI, that so I assumed it was automatically included now. Try running this command:
xcode-select --install
If you see an error message that developer tools are already installed (and still header files can't be found), wipe out any existing one to do a fresh installation:
sudo rm -rf /Library/Developer/CommandLineTools
Ubuntu
(as per this answer)
sudo apt-get install libc6-dev
Alpine Linux
(as per this comment)
apk add libc-dev
Mac OS Mojave
The accepted answer no longer works. When running the command xcode-select --install it tells you to use "Software Update" to install updates.
In this link is the updated method:
Open a Terminal and then:
cd /Library/Developer/CommandLineTools/Packages/
open macOS_SDK_headers_for_macOS_10.14.pkg
This will open an installation Wizard.
Update 12/2019
After updating to Mojave 10.15.1 it seems that using xcode-select --install works as intended.
ubuntu users:
sudo apt-get install libc6-dev
specially ruby developers that have problem installing gem install json -v '1.8.2' on their VMs
I know my case is rare, but I'll still add it here for someone who troubleshoots it later.
I had a Linux Kernel module target in my Makefile and I tried to compile my user space program together with the kernel module that doesn't have stdio.
Making it a separate target solved the problem.
I had the same problem. I installed "XCode: development tools" from the app store and it fixed the problem for me.
I think this link will help:
https://itunes.apple.com/us/app/xcode/id497799835?mt=12&ls=1
Credit to Yann Ramin for his advice. I think there is a better solution with links, but this was easy and fast.
Good luck!

Compilation errors in RHEL 5 libudev.h No such file or directory

All,
I'm trying to compile some code that compiles in Ubuntu after getting the udev library from "apt-get". I am trying to get it to compile in RedHat 5 but am getting the following compile errors:
error: libudev.h: No such file or directory
The question is similar to: QSerialDevice: Compilation error "libudev.h: No such file or directory"
However, instead of the failure happening on Ubuntu, it's happening on RedHat 5. I tried finding the RPM files for the udev library and got one RPM file from the following link. The RPM file was unsuccessful installing when I double clicked it stating:
"Cannot install source packages"
"No packages were given for installation"
http://www.linuxquestions.org/questions/linux-software-2/i-need-libudev-or-udev-devel-for-red-hat-5-a-4175422051/
udev-147-2.42.el6.src.rpm is the name of the RPM
Any help would be appreciated. Doing a search on Google is starting to lead me to believe that this libudev.h is only for Ubuntu? Is this true!?
Its only available for RedHat 6 not in RedHat 5.
http://pkgs.org/centos-6-rhel-6/centos-rhel-i386/libudev-devel-147-2.41.el6.i686.rpm.html

Resources