Arman92 / go-tdlib

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

error /usr/bin/ld: cannot find -lc++ #91

Open imanborumand opened 3 years ago

imanborumand commented 3 years ago

Hi I get the following command when running

command: go run basicAuthorization.go

error:

github.com/Arman92/go-tdlib /usr/bin/ld: cannot find -lc++ collect2: error: ld returned 1 exit status

ubuntu 20.04

please help me

@Arman92 thank arman jan

dfelici87 commented 3 years ago

Hi,

I have the same problem... Any news?

thanks

Arman92 commented 3 years ago

Please use v2 branch while I merge it with master/main.

DukeAnn commented 3 years ago
Step 10/13 : RUN 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
 ---> Running in edae96c0db0b
go: downloading github.com/Arman92/go-tdlib v1.0.1-0.20210806020223-e1bab7be7026
# github.com/Arman92/go-tdlib/client
/usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lc++
collect2: error: ld returned 1 exit status
Error response from daemon: The command '/bin/sh -c 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' returned a non-zero code: 2
Failed to deploy '<unknown> Dockerfile: tdlib/Dockerfile': Can't retrieve image ID from build stream

Upgrading still doesn't work

miketsukuba commented 2 years ago

Hi I have the same problem, with Ubuntu 18, 64 Bit, golang 1.13 Also for the other td libraraies like (ltdjson_static, _private, ...), I saw some libraries has only .a file and .so files are not built

Would you please explain how to "use v2 branch while merge it with master/main"? Thanks in advance.

dfelici87 commented 2 years ago

Hi,

I try to use v2 version... i have the same problem! :-(

Can you help us @Arman92 please?

thanks.

miketsukuba commented 2 years ago

@dfelici87 As far as I understood to use the new version of https://github.com/Arman92/go-tdlib which is based on lc++ (not lstdc++) you need to build tdlib based on lc++ as:

https://github.com/tdlib/td/issues/780

apt-get install make git zlib1g-dev libssl-dev gperf php cmake clang-6.0 libc++abi-dev libc++-dev git clone https://github.com/tdlib/td.git cd td rm -rf build mkdir build cd build export CXXFLAGS="-stdlib=libc++" CC=/usr/bin/clang-6.0 CXX=/usr/bin/clang++-6.0 cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=../tdlib -DCMAKE_AR=/usr/bin/llvm-ar-6.0 -DCMAKE_NM=/usr/bin/llvm-nm-6.0 -DCMAKE_OBJDUMP=/usr/bin/llvm-objdump-6.0 -DCMAKE_RANLIB=/usr/bin/llvm-ranlib-6.0 .. cmake --build . --target install cd .. cd .. ls -l td/tdlib

this may resolve the -lc++ issue.

Laky-64 commented 2 years ago

Same problem, but i'm from alpine, i can't install libc++abi-dev

Laky-64 commented 2 years ago

*Edit: Same problem also on Arm64v8 & Arm32v7 (Buster)

My Docker Machine: https://github.com/DockerTDLib/TDLib/blob/main/linux/Dockerfile

Docker machine from Docker Hub https://hub.docker.com/repository/docker/laky64/tdlib

My Docker Building Machine:

FROM laky64/tdlib:linux-arm64 AS golang
RUN apt install libc++-dev libc++abi-dev -y
RUN git clone https://github.com/OwlGramDev/TelegramDCStatus
RUN cd TelegramDCStatus && go build -o /usr/src/outputs/TgStatus .
chenshuanj commented 2 years ago
# cd /root/go/pkg/mod/github.com/\!arman92/go-tdlib@v1.0.0
# vi tdlib.go

replace "-lc++" to "-lstdc++"

# cd /project-dir
# rm -rf ~/.cache/go-build
# CC=/opt/rh/devtoolset-9/root/usr/bin/gcc CXX=/opt/rh/devtoolset-9/root/usr/bin/g++ go build

It works.

Pichas commented 7 months ago

for docker build

RUN sed -i 's|-lc++|-lstdc++|p' /go/pkg/mod/github.com/\!arman92/go-tdlib@v1.0.0/tdlib.go

RUN 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/binary main.go