V: failed to compile v.c on macOS

Created on 23 Jun 2019  ·  10Comments  ·  Source: vlang/v

macOS: 10.14.5 (18F132)

$ cc -w -o vc v.c           # Build it with Clang or GCC
In file included from v.c:3:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.1/include/inttypes.h:30:15: fatal error: 
      'inttypes.h' file not found
#include_next <inttypes.h>
              ^~~~~~~~~~~~
1 error generated.

Solution

On macOS 10.15.3:

git clone --depth=1 https://github.com/vlang/v
cd v/
make SDKROOT=`xcrun --show-sdk-path`

On macOS 10.15 (Reference)

xcode-select --install    # install command line tools and headers.
export CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
cd /path/to/v/repo
make

On macOS 10.14:

xcode-select --install    # install command line tools and headers.
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
Bug

Most helpful comment

I've reproduce with compile error, it tried to look for the missing header in /usr/include/inttypes.h

I think this discussion may help:
https://stackoverflow.com/questions/52509602/cant-compile-c-program-on-a-mac-after-upgrade-to-mojave

Installed this appear to resolve my issue

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

All 10 comments

I'm all OK
macOS 10.13.6

I'm running macOS 10.14.5 (18F132).

I'm on 10.14.5, I remember someone mentioned the need to installed additional headers on Mojave.

Do you have an includes folder?
ls /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/

Both files exist on my macOS 10.14.5:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.1/include/inttypes.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/inttypes.h

I've reproduce with compile error, it tried to look for the missing header in /usr/include/inttypes.h

I think this discussion may help:
https://stackoverflow.com/questions/52509602/cant-compile-c-program-on-a-mac-after-upgrade-to-mojave

Installed this appear to resolve my issue

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

Fixed with steps below:

  1. Run xcode-select --install to install command line tools and headers.
  2. Run open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

This better be mentioned on V installation tutorial (for macOS part). :)

@iredmail Can you do a pull request for this please ?

Someone already created one: #436

I am getting the same error on windows 8.1 mingw-64. Should I create a new issue?
$ gcc -std=gnu11 -w -o v.exe v.c v.c:3:10: fatal error: inttypes.h: No such file or directory #include <inttypes.h> // int64_t etc ^~~~~~~~~~~~ compilation terminated.

Yes please. This issue title is about “macOS” and CLOSED. :(

Was this page helpful?
0 / 5 - 0 ratings

Related issues

radare picture radare  ·  3Comments

PavelVozenilek picture PavelVozenilek  ·  3Comments

penguindark picture penguindark  ·  3Comments

taojy123 picture taojy123  ·  3Comments

clpo13 picture clpo13  ·  3Comments