Hello Nim community. Thank you for any effort looking into this.
I am facing problem with static compilation of nim program using db_mysql module and musl-gcc.
Downloaded mysql-8.0.28-linux-glibc2.17-x86_64-minimal (this is already compiled) and openssl-1.1.1m (compiled myself) to current working directory of project and then include headers and libs with "pass" options.
Variables (from Justfile: mysql_include, mysql_libs) are filled with proper mysql_config or pkg-config info. mysql_config --libs or pkg-config --static --libs mysqlclient same for ssl libs and includes.
nim \
--dynlibOverride:ssl \
--dynlibOverride:crypto \
-d:ssl \
--passL:"-static" \
--passC:"{{ssl_include}}" \
--passL:"{{ssl_libs}}" \
--passC:"{{mysql_include}}" \
--passL:"{{mysql_libs}}" \
--gcc.exe:musl-gcc \
--gcc.linkerexe:musl-gcc \
compile {{main_file}}
Resulting executable is statically linked but even after succesfull compilation program throwing error when I try to run it.
could not load: (libmysqlclient|libmariadbclient).so(|.20|.19|.18|.17|.16|.15)
I am willing to provide libmysqlclient.so library to my application on every machine but even with LD_LIBRARY_PATH or LD_PRELOAD this seems not work. Maybe compiled binary is searching somewhere else for this .so library?
Not able to solve this for few days, so any help is appreciate. Am I doing something horribly wrong?
As an alternative, does anyone know any simple "static" mysql client library to use instead of oracle-mysql, mariadb and such? I tried theirs C connectors but with same result.
Actually I did but result was: Dynamic loading not supported
writev(2, [{iov_base="", iov_len=0}, {iov_base="Dynamic loading not supported", iov_len=29}], 2Dynamic loading not supported) = 29
As I can see, with default gcc I am able to build statically, but nevertheless default gcc still depends on calls so it is not a solution.
/usr/bin/ld: /home/marek/.cache/nim/resticw_d/stdlib_system.nim.c.o: in function `nimLoadLibrary': stdlib_system.nim.c:(.text+0x1227d): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking