Arman92 / go-tdlib

Golang Telegram TdLib JSON bindings
GNU General Public License v3.0
435 stars 101 forks source link

Missing -lstdc++ in sources #98

Open Vladius25 opened 2 years ago

Vladius25 commented 2 years ago

I have installed tdlib from disto repo and trying to build my app:

$ go build cmd/app.go 
# github.com/Arman92/go-tdlib
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/11/../../../../lib64/libtdutils.a(misc.cpp.o): undefined reference to symbol '_ZNSt6localeD1Ev@@GLIBCXX_3.4'
/usr/bin/ld: /usr/lib64/libstdc++.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

But following works fine:

$ export CGO_LDFLAGS="-lstdc++"
$ go build cmd/app.go 

-lstdc++ is missing there https://github.com/Arman92/go-tdlib/blob/2454be49c3413c5529a292e3958305936d4ba490/tdlib.go#L6

And example from README isn't working also. Try go build with -x flag and you will see that -lstdc++ will not be added.

$ go build --ldflags "-extldflags '-static -L/usr/local/lib -ltdjson_static -ltdjson_private -ltdclient -ltdcore -ltdactor -ltddb -ltdsqlite -ltdnet -ltdutils -ldl -lm -lssl -lcrypto -lstdc++ -lz'" -o /tmp/getChats getChats.go