相关疑难解决方法(0)

升级到Mojave后无法在Mac上编译C程序

我在终端上使用了gcc命令来编译C程序但突然间,在我的Mac操作系统更新后(到macOS 10.14 Mojave和XCode 10.0),我开始收到消息:

test.c:8:10: fatal error: stdio.h: No such file or directory
#include <stdio.h>
         ^~~~~~~~~
compilation terminated.
Run Code Online (Sandbox Code Playgroud)

我已经安装了gcc,因为我可以找到它/usr/local/bin并且那里确实有一个gcc.我尝试在我的其他iMac上运行相同的文件,它没有任何问题.

我试过运行xcode-select --install它已经安装好了,因此它没有解决我现在遇到的问题.我猜测路径搞砸了,因为gcc在我开始复制并粘贴其他资源中的一些命令来解决此问题后,它似乎无法找到.

希望对此有所帮助.

c macos terminal gcc

145
推荐指数
7
解决办法
6万
查看次数

macOS'wchar.h'找不到文件

在使用XCode 6.0.1的OS X 10.9.5下,当我尝试make从终端运行时,我遇到了以下问题:

fatal error: 'wchar.h' file not found
Run Code Online (Sandbox Code Playgroud)

最近升级到Mavericks之前没有发生过这个问题.

macos xcode clang

51
推荐指数
5
解决办法
3万
查看次数

C - 编译程序时出现多个警告“指针缺少可空性类型说明符”,我该怎么办?

我最近开始在编译 C 程序时遇到问题,从stdio.hstdlib.h等不同的 C 包中收到 10、20 或 100 个警告。

警告有所不同,但通常是这样说的:

/usr/local/include/_stdio.h:93:16: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or
      _Null_unspecified) [-Wnullability-completeness]
        unsigned char   *_base;
Run Code Online (Sandbox Code Playgroud)

我的程序仍然可以编译并运行良好,但我担心这需要修复,而且在终端中收到所有这些警告也非常烦人。

我几乎可以肯定这些警告在我将系统更新到 macOS Catalina 后开始显示,但我不知道从哪里开始解决它。

更具体地说,当我像这样编译一个简单的helloworld.c程序时

#include <stdio.h>

int main (void) {
    printf("Hello World!"); 
    return 0; 
}
Run Code Online (Sandbox Code Playgroud)

使用以下命令:

make helloworld 
Run Code Online (Sandbox Code Playgroud)

或者

gcc helloworld.c -o helloworld 
Run Code Online (Sandbox Code Playgroud)

..我收到以下警告,即使程序实际编译。

In file included from helloworld.c:1:
In file included from /usr/local/include/stdio.h:64:
/usr/local/include/_stdio.h:93:16: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, …
Run Code Online (Sandbox Code Playgroud)

c macos stdio clang macos-catalina

8
推荐指数
1
解决办法
1978
查看次数

Catalina C ++:使用&lt;cmath&gt;标头会产生错误:全局命名空间中没有名为“ signbit”的成员

从Mojave升级到Catalina后,在环境中进行设置:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk。

我无法编译使用<cmath>标头的程序。

我尝试更改CFLAGS,CCFLAGS,CXXFLAGS以指向不变的MacOSSDK位置

Scanning dependencies of target OgreMain
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f OgreMain/CMakeFiles/OgreMain.dir/build.make OgreMain/CMakeFiles/OgreMain.dir/build
[  0%] Building CXX object OgreMain/CMakeFiles/OgreMain.dir/src/OgreASTCCodec.cpp.o
cd /Users/roman/Downloads/ogre-1.12.2/build/OgreMain && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  -DOgreMain_EXPORTS -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0 -I/Users/roman/Downloads/ogre-1.12.2/OgreMain/src/OSX -I/Users/roman/Downloads/ogre-1.12.2/OgreMain/include/Threading -I/Users/roman/Downloads/ogre-1.12.2/OgreMain/src -I/Users/roman/Downloads/ogre-1.12.2/build/Dependencies/include -I/Users/roman/Downloads/ogre-1.12.2/OgreMain/include -I/Users/roman/Downloads/ogre-1.12.2/build/include -I/Users/roman/Downloads/ogre-1.12.2/OgreMain -isystem /usr/local/include  -Wall -Winit-self -Wcast-qual -Wwrite-strings -Wextra -Wundef -Wmissing-declarations -Wno-unused-parameter -Wshadow -Wno-missing-field-initializers -Wno-long-long -Wno-inconsistent-missing-override  -msse -O3 -DNDEBUG -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -fPIC -fvisibility=hidden -fvisibility-inlines-hidden   -std=c++11 -o CMakeFiles/OgreMain.dir/src/OgreASTCCodec.cpp.o -c /Users/roman/Downloads/ogre-1.12.2/OgreMain/src/OgreASTCCodec.cpp
In file included from /Users/roman/Downloads/ogre-1.12.2/OgreMain/src/OgreASTCCodec.cpp:29:
In file included from /Users/roman/Downloads/ogre-1.12.2/OgreMain/src/OgreStableHeaders.h:40:
In file included from /Users/roman/Downloads/ogre-1.12.2/OgreMain/include/OgrePrerequisites.h:309:
In file included …
Run Code Online (Sandbox Code Playgroud)

c++ macos clang toolchain macos-catalina

8
推荐指数
6
解决办法
294
查看次数

如何确保我的默认 C/C++ 编译器是 GCC

我正在尝试在 macOS 上从源代码安装 Riak ( https://docs.riak.com/riak/kv/2.2.3/setup/installing/mac-osx.1.html#installing-from-source )。

有一个注释:

Riak 不会使用 Clang 进行编译。请确保您的默认 C/C++ 编译器是 GCC

如何找出默认编译器以及如何更改它?

macOS Catalina (10.15.4),命令打印:

$ which clang
/usr/bin/clang
$ which gcc
/usr/bin/gcc
Run Code Online (Sandbox Code Playgroud)

c++ macos gcc clang riak

8
推荐指数
1
解决办法
2万
查看次数

xcode已安装但找不到macOS_SDK_headers_for_macOS_10.14.pkg

我在编译 gcc 时遇到问题,可以追溯到 Catalina 存在 xcode 问题,因此我在 OS X mojave 上安装 Haskell 时参考了此处的链接“macOS_SDK_headers_for_macOS_10.14.pkg 与此版本的 macOS 不兼容”并尝试解决问题。但是,虽然我重新安装了xcode,但我无法打开macOS_SDK_headers_for_macOS_10.14.pkg,因为该文件不在/Library/Developer/CommandLineTools/Packages/中。我的文件看起来像;

MacBook-Pro:CommandLineTools myname$ ls
Library SDKs    usr
Run Code Online (Sandbox Code Playgroud)

我在哪里可以找到该文件?我应该手动将 pkg 添加到文件夹中吗?

xcode gcc gcc-warning

5
推荐指数
1
解决办法
1039
查看次数

标签 统计

macos ×5

clang ×4

gcc ×3

c ×2

c++ ×2

macos-catalina ×2

xcode ×2

gcc-warning ×1

riak ×1

stdio ×1

terminal ×1

toolchain ×1