-
m-relay
<sarg22:matrix.org> How do I statically compile monero? "make release-static" still has dynamically linked libs
-
m-relay
<ofrnxmr:monero.social> > Dependencies need to be built with -fPIC. Static libraries usually aren't, so you may have to build them yourself with -fPIC. Refer to their documentation for how to build them.
-
m-relay
<ofrnxmr:monero.social> Just a guess. Idk the answer to your question
-
m-relay
<jbabb:cypherstack.com> You might check out existing work in flutter_libmonero. I like how MrCyjaneK’s monero_c handles it now, which is what both Cake Wallet and Stack Wallet’s flutter_libmonero use to build a static monero. Prior to monero_c we did things differently which may provide insight into alternative methods if monero_c isn’t a good example. Stack supported more platforms using the sa<clipped message>
-
m-relay
<jbabb:cypherstack.com> me statically-compiled monero by using some hefty scripts tailored to each os, I can link that older (but still working) code if the current state isn’t helpful
-
m-relay
<jbabb:cypherstack.com> We basically would and still do build a series of static libs covering all of monero’s deps. We also had a great bounty submission once that mostly used monero’s own contrib system which is probably ultimately best and most well-supported
-
m-relay
<jbabb:cypherstack.com> If you want old flutter_libmonero links because neither contrib nor monero_c elucidate the issue, I can spit them out
-
m-relay
<jbabb:cypherstack.com> But I’d probably base a modern rework of our (Stack’s) old static compilation process on contrib as much as possible
-
m-relay
<jbabb:cypherstack.com> If you want old flutter_libmonero links because neither contrib nor monero_c elucidate the issue, I can spit them out
-
m-relay
<jbabb:cypherstack.com> But I’d probably base a modern rework of our (Stack’s) old static compilation process upon contrib as much as possible
-
m-relay
<sarg22:matrix.org> so I should build every dependency statically then compile linking static libs?
-
m-relay
<jbabb:cypherstack.com> That’s what we do
-
m-relay
<sarg22:matrix.org> Okay, after statically compiling all deps is there a change in the command or is make release-static enough?
-
moneromooo
make release-static will build a dynamic binary, despite the name. It just links statically what it can.
-
moneromooo
Static binaries are seldom used nowadays.
-
moneromooo
You will need to monkey with CMakeLists.txt to pass -static to gcc, and possibly some other stuff.
-
moneromooo
cmake might have ready made functions to set that up, might want to check.
-
sech1
it's "set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")" plus all the dependencies must be statically compiled
-
sech1
and it doesn't work well with glibc, but it works with musl (Alpine Linux must be used for compilation)
-
sech1
But it's much easier to compile everything but glibc statically
-
sech1
then you only need to care about glibc version that your binary requires