Skip to content
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

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

Open
imanborumand opened this issue Sep 10, 2021 · 10 comments
Open

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

imanborumand opened this issue Sep 10, 2021 · 10 comments

Comments

@imanborumand
Copy link

imanborumand commented Sep 10, 2021

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
Copy link

Hi,

I have the same problem... Any news?

thanks

@Arman92
Copy link
Owner

Arman92 commented Sep 13, 2021

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

mritd added a commit to mritd/poetbot that referenced this issue Sep 20, 2021
switch v2 version

ref Arman92/go-tdlib#91

Signed-off-by: mritd <[email protected]>
@DukeAnn
Copy link

DukeAnn commented Dec 2, 2021

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
Copy link

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
Copy link

Hi,

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

Can you help us @Arman92 please?

thanks.

@miketsukuba
Copy link

@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:

tdlib/td#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
Copy link

Laky-64 commented Mar 19, 2022

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

@Laky-64
Copy link

Laky-64 commented Mar 19, 2022

*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
Copy link

# cd /root/go/pkg/mod/github.com/\!arman92/[email protected]
# 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
Copy link

Pichas commented Apr 27, 2024

for docker build

RUN sed -i 's|-lc++|-lstdc++|p' /go/pkg/mod/github.com/\!arman92/[email protected]/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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants