Hello. I’m using Linux. I installed both the Clang compiler and the Musl standard C library through the repository. I tried to compile a “hello world” program through Clang using the Musl stdio.h, but it failed. I put the following line at the beginning of the program:
#include </usr/include/x86_64-linux-musl/stdio.h>
But at the compiling time (in verbose mode) it returned the following error:
==============================
(…)
#include “…” search starts here:
#include <…> search starts here:
/usr/local/include
/usr/lib/llvm-11/lib/clang/11.0.1/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
In file included from /home/pureos/hello.c:1:
/usr/include/x86_64-linux-musl/stdio.h:26:10: error: ‘bits/alltypes.h’ file not found with include; use “quotes” instead
#include <bits/alltypes.h>
^~~~~~~~~~~~~~~~~
“bits/alltypes.h”
==============================
It appears that it doesn’t recognize the “bits” directory inside the “x86_64-linux-musl” directory, but I saw that it DOES exist.
Well, using “clang hello.c -I /usr/include/x86_64-linux-musl/” compiled but didn’t worked. After all, an analysis of the compiled program via the “hexdump -C a.out” command strangely showed that it keeps using the Glibc library, and that’s the thing I want to avoid.
There’s no clear reason for the compiler to have used the Glibc, since I clear specified in the source code the absolute path /usr/include/x86_64-linux-musl/stdio.h; I tried both the angled (<>) include and quotes (“”), and none of these worked.
Running the “ldd” command in the resulting “a.out” file, it shows that it’s linked against the “/lib/x86_64-linux-gnu/libc.so.6” file; however, I wonder if it shouldn’t be linked against the “/lib/x86_64-linux-musl/libc.so” or perhaps “/lib/ld-musl-x86_64.so.1” files if everything ran as expected.
Any help is welcome, regards.