* [musl] [Question] Statically compile and link C++ against musl on Ubuntu (musl-gcc)
@ 2021-12-24 7:37 Timo Lange
2021-12-24 9:47 ` Markus Wichmann
0 siblings, 1 reply; 2+ messages in thread
From: Timo Lange @ 2021-12-24 7:37 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 1128 bytes --]
Hey there.
I am currently compiling my C++ project against musl.
The reason is that I need a fully static executable and glibc does not seem to be suited for that case.
Currently I am doing the compilation inside an Alpine based Docker image. Using buildx and QEMU I also cross-compile for aarch64 - which is terribly slow.
Apart from that, the problem I am facing with this approach is that a few tools I want to use (static code analysis, FOSS scan, etc.) do not run under Alpine, as they require an Ubuntu loader.
Of course I tried making them run under Alpine but I feel this is not a proper solution. Anyhow I have failed so far.
So I came across musl-tools, resp. musl-gcc which is a wrapper around GCC on Ubuntu that "replaces" glibc libraries by musl. I am able to compile a simple C program with this, but not C++. It fails including any C++ header.
I assume it supports only C, as the name musl-gcc indicates.
Is there any way to compile a C++ program on Ubuntu entirely static (against musl)?
And if so, would this work with a "proper" amd64 -> aarch64 cross-compiler? So I could get rid of QEMU.
[-- Attachment #2: Type: text/html, Size: 2714 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [musl] [Question] Statically compile and link C++ against musl on Ubuntu (musl-gcc)
2021-12-24 7:37 [musl] [Question] Statically compile and link C++ against musl on Ubuntu (musl-gcc) Timo Lange
@ 2021-12-24 9:47 ` Markus Wichmann
0 siblings, 0 replies; 2+ messages in thread
From: Markus Wichmann @ 2021-12-24 9:47 UTC (permalink / raw)
To: musl
On Fri, Dec 24, 2021 at 07:37:04AM +0000, Timo Lange wrote:
> Is there any way to compile a C++ program on Ubuntu entirely static (against musl)?
musl is a libc implementation. As such it contains all standard C
headers and all POSIX functions. In order to use the C++ standard
library with musl, however, you require an implementation of the C++
standard library. libcxx has, to my knowledge, been the most popular
choice to go along with musl, though GCC seems to like its libstdc++
more. I am sure a search engine will counsel you further in this matter
> And if so, would this work with a "proper" amd64 -> aarch64 cross-compiler? So I could get rid of QEMU.
musl can be cross-compiled with the standard options for
cross-compilation. You compile a cross-gcc (and its libgcc) for the
target you want, then compile musl with that cross-gcc, then compile g++
with musl, and then that somehow already contains a libstdc++, or else
you use libcxx. Again, I suggest a search engine.
Ciao,
Markus
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-24 9:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-24 7:37 [musl] [Question] Statically compile and link C++ against musl on Ubuntu (musl-gcc) Timo Lange
2021-12-24 9:47 ` Markus Wichmann
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).