一些command line的笔记

clang -S -emit-llvm test.cpp -o test.ll -o0 在使用这个clang命令行是遇到了问题:

test.cpp:1:10: fatal error: 'stdio.h' file not found 1 | #include <stdio.h> | ^~~~~~~~~ 1 error generated.

clang没有找到stdio.h库相关的文件。

会不会是stdio.h没有安装?用的MacOS, stdio.h应该在Xcode工具里

运行 xcode-select --print-path,得到 /Library/Developer/CommandLineTools, 说明已经安装了Xcode工具

所以是clang没有找到这个头文件。这里用clang -v 打印clang默认寻找的根目录:运行 clang -v

得到

clang version 17.0.6

Target: arm64-apple-darwin21.3.0

Thread model: posix

InstalledDir: /usr/local/bin

说明clang寻找的目录是/usr/local/bin 而不是MacOS里的/Library/Developer/CommandLineTools

所以改变寻找的系统根目录:加上 -isysroot $(xcrun --show-sdk-path), 运行 clang -S -emit-llvm test.cpp -o test.ll -O0 -isysroot $(xcrun --show-sdk-path) 成功了。

设置别名方便之后使用:alias clang="clang -isysroot $(xcrun --show-sdk-path)"

全部评论

相关推荐

千疮百孔的象牙塔:我也在捣鼓im,你这个im好奇怪的样子,单看简历get不到点,im的消息及时性,消息可靠性,然后系统的可扩展性这几个关键问题都是怎么解决的从简历描述get不到,具体说消息怎么传,消息怎么推送,消息怎么存,消息安全怎么做的这些点感觉对应不起来
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务