-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static version of tdjson? #8
Comments
We haven't tested static linking of the libtdjson_static library to Golang code, but it looks like Golang (using cgo) supports static linking of С libraries and everything should work fine. You will also need to statically link all TDLib dependencies, namely ilibtdactor, libtddb, libtdnet, libtdsqlite, libtdutils, libcrypto, libssl, libz and standard C++ library (libc++/libstdc++). What errors do you get? |
@levlam seems like the libs order is the key. After researching /*
#cgo LDFLAGS: -ltdjson_static -ltdjson_private -ltdclient -ltdcore -ltdactor -ltddb -ltdsqlite -ltdnet -ltdutils -lstdc++ -lssl -lcrypto -ldl -lz -lm
#include <stdlib.h>
#include <td/telegram/td_json_client.h>
#include <td/telegram/td_log.h>
*/
import "C" After this I compiled the binary, but with few warnings:
Because of it seems like Go static builds linked with
Article with very similar problem: To finalize: |
I have a few suggestions for you:
|
@levlam thanks for suggestions!
|
|
@levlam thanks for advices. For me easier to link statically against TDLib only. Other libs like OpenSSL, ZLib and others is simpler to install on target system from package manager. For readers: /*
#cgo LDFLAGS: -ltdjson_static -ltdjson_private -ltdclient -ltdcore -ltdactor -ltddb -ltdsqlite -ltdnet -ltdutils -lstdc++ -lssl -lcrypto -ldl -lz -lm
#include <stdlib.h>
#include <td/telegram/td_json_client.h>
#include <td/telegram/td_log.h>
*/
import "C" Compile dynamic binary with default command:
Now your binary will depends only from libs like OpenSSL and zLib. |
I have a full tdlib-tdjson binding package here (Autogenerated all types/methods from tdlib.tl) : https://github.com/Arman92/go-tdlib |
I am using Golang with C-bindings to use this lib, but I also want to compile static binary. There is shared version
/usr/local/lib/libtdjson.so
, but there is no static one. I tried to uselibtdjson_static.a
, but seems like this is works for C++ only.The text was updated successfully, but these errors were encountered: