<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Thanks to everyone for the advice!<div class=""><br class=""></div><div class="">I guess there are two main approaches: either link statically, as much stuff as possible, or continue with shared libraries and rely on the system’s package management support.</div><div class=""><br class=""></div><div class="">I’m already using a container for CI. Are there any issues with Erlang running on Alpine Linux (I think there is a problem in ver 3.5 which switched from OpenSSL to LibreSSL)? Building on this distribution using the Musl C library could simplify the static approach.<br class=""><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Radu</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 25 Oct 2016, at 18:59, John Doe <<a href="mailto:donpedrothird@gmail.com" class="">donpedrothird@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">For portable app you'll need to compile as many libs as possible statically. With pure C libraries it's usually easy to do so, but you will have a lot of problems with c++ executables and libraries, as libstdc++ has different ABI in different gcc releases. You'd need to compile libstdc++ statically, and also anything that links against c++ code with -static-libstdc++ and -fPIC. The libstdc++ itself should be built with -fPIC flag. <div class="">When I need portable binaries I compile gcc myself from sources prior to linking against static libstdc++, with </div><div class=""><span style="color:rgb(128,128,128);font-style:italic;font-family:"bitstream vera sans mono"" class="">./configure CXXFLAGS=-fPIC CFLAGS=-fPIC --enable-languages=c,c++ --disable-gnu-unique-object --disable-multilib </span></div><div class=""><br class=""></div><div class="">Also you could get problems with openssl if you use the crypto app. There are many different versions built of openssl each with different set of algorithms, so it is better to compile your own openssl with something like this:</div><div class=""><pre style="font-family: 'bitstream vera sans mono';" class=""><span style="color:rgb(128,128,128);font-style:italic" class="">wget <a href="https://www.openssl.org/source/openssl-1.0.2h.tar.gz" class="">https://www.openssl.org/source/openssl-1.0.2h.tar.gz</a><br class=""></span><span style="color:rgb(128,128,128);font-style:italic" class="">tar -xvzf openssl-1.0.2h.tar.gz<br class=""></span><span style="color:rgb(128,128,128);font-style:italic" class="">cd openssl-1.0.2h/<br class=""></span><span style="color:rgb(128,128,128);font-style:italic" class="">./config --prefix=/usr shared -fPIC<br class=""></span><span style="color:rgb(128,128,128);font-style:italic" class="">make depend && make && make install</span></pre></div><div class="">and then have otp built with</div><div class=""><span style="color:rgb(128,128,128);font-style:italic;font-family:"bitstream vera sans mono"" class="">--disable-dynamic-ssl-lib --with-ssl=/usr/ --enable-smp-support --without-termcap --enable-dirty-schedulers --enable-builtin-zlib</span> </div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">You can even patch the OTP if you need it to work with relative install path (warning - the patch contains bashisms): <a href="http://pastebin.com/FJtRNRMJ" class="">http://pastebin.com/FJtRNRMJ</a></div><div class=""><br class=""></div><div class="">All that stuff should be done on a dedicated build server or VPS, as it could break a lot of things in the system. But as the result the app is very portable. If built on x64 box, it would work on most x64 bit linux servers with any distro.<br class=""></div><div class=""><br class=""></div><div class=""><div class="">nif apps should be also built with something like this:</div><div class=""><br class=""></div><div class=""><span style="font-family:monospace" class=""><span style="" class="">{"CXXFLAGS", "$CXXFLAGS -std=c++11 -Wall -fPIC -g3 -static-libstdc++"},</span></span></div><div class=""><span style="font-family: monospace;" class="">{"DRV_LDFLAGS", "$DRV_LDFLAGS c_src/libsomeapp.a c_src/system/lib/libsnappy.a c_src/system/lib/liblz4.a c_src/system/lib/libz.a c_src/system/lib/libbz2.a /usr/lib64/</span><span style="font-family:monospace" class=""><br class=""></span></div><div class=""><span style="font-family:monospace" class="">gcc/x86_64-pc-linux-gnu/5.3.0/libstdc++.a -static-libstdc++"}]}.<br class=""></span></div></div><div class=""><span style="font-family:monospace" class=""><br class=""></span></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">2016-10-25 15:35 GMT+03:00 Radu Popescu <span dir="ltr" class=""><<a href="mailto:i.radu.popescu@gmail.com" target="_blank" class="">i.radu.popescu@gmail.com</a>></span>:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello!<br class="">
<br class="">
I'm developing an Erlang application which is structured as an OTP release. It contains OTP applications and some native executables (written in C++). One of the Erlang dependencies also requires libsodium.<br class="">
<br class="">
When the time will come to deploy this - mostly to RH and Ubuntu/Debian servers, the idea is to have something as self-contained as possible.<br class="">
<br class="">
Are there best practices for how to handle C library dependencies for an Erlang/OTP release? I appreciate any advice.<br class="">
<br class="">
Thanks!<br class="">
<br class="">
Best regards,<br class="">
Radu<br class="">
______________________________<wbr class="">_________________<br class="">
erlang-questions mailing list<br class="">
<a href="mailto:erlang-questions@erlang.org" target="_blank" class="">erlang-questions@erlang.org</a><br class="">
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank" class="">http://erlang.org/mailman/list<wbr class="">info/erlang-questions</a><br class="">
</blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></body></html>