简体   繁体   English

如何使用系统提供的 Clang 和 libc 编译 C 程序,例如。 穆尔?

[英]How to compile C program using Clang and libc other than provided by system, eg. musl?

According to clang's documentation ,根据 clang 的 文档

Clang supports a wide variety of C standard library implementations. Clang 支持多种 C 标准库实现。

But it lacks the information about how to actually use desired libc.但它缺乏有关如何实际使用所需 libc 的信息。

For example, how to use clang with musl if my system provides Glibc by default?例如,如果我的系统默认提供 Glibc,如何将 clang 与 musl 一起使用? Do I need musl-built clang itesl?我需要 musl-built clang itesl 吗?

From official document of musl it may be not easy to do so.从 musl 的官方文档来看,这样做可能并不容易。

You can try to link against libc.so or libc.a in your musl install path, and instruct clang not to link standard libc.您可以尝试在 musl 安装路径中链接libc.solibc.a ,并指示 clang 不要链接标准 libc。 Also you need some way to let it include headers form musl's include path.此外,您还需要某种方式让它包含来自 musl 的include路径的标题。

There can be problems.可能会有问题。 I'm not sure if gcc-targeted musl can work fine with clang compiled object.我不确定以 gcc 为目标的 musl 是否可以与 clang 编译对象一起正常工作。

And here's someone's work that may help: https://github.com/dslm4515/CMLFS这是某人的工作可能会有所帮助: https : //github.com/dslm4515/CMLFS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM