go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1 /usr/bin/ld: cannot find -lgdal
Asked Answered
S

4

7

I am trying to run go build on my sources.

go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -lgdal
collect2: error: ld returned 1 exit status

My LD_LIBRARY_PATH variable contains /home/fzd/project/lib64, the path to the dir of the libgdal.so file. My PKG_CONFIG_PATH contains the path to the dir of a .pc file with the following contents :

prefix=/home/fzd/project
exec_prefix=${prefix}
libdir=${prefix}/lib64
deplibdir=${prefix}/lib64
includedir=${prefix}/include

Name: myLibs
Description: Libs
Requires:
Version: v1.0
Libs: -L${deplibdir} -lgdal
Cflags: -I${includedir}

I don't know which variable to check. Everything seems fine, and the fun part is that, when I clone my repo elsewhere, I don't have the issue (same LD_LIBRARY_PATH, etc.)

Does anyone have a clue about what I could check?

I am using go1.11.1, on CentOS7.6.

Satiety answered 11/6, 2019 at 16:19 Comment(0)
S
9

Here are a few things I did to solve this issue:

  • rm -rf ~/.cache/go-build : this contained a few build artifacts
  • rm -rf ${MyProject}/{bin,pkg} : for the same reason
Satiety answered 12/6, 2019 at 15:59 Comment(0)
A
2

try yum install glibc-static.x86_64 -y

I've came across the error like

/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -ldl
/usr/bin/ld: cannot find -lpthread

and the glibc-static lib fix it.

Amphibolite answered 7/5, 2021 at 7:16 Comment(1)
There is also a libstdc++-staticRockfish
G
2

The following steps worked for me:

yum install glibc-static.x86_64 libstdc++-static -y

And then removing last build cache

rm -rf ~/.cache/go-build

And then exporting CXXFLAGS

export CXXFLAGS="-stdlib=libstdc++" CC=/usr/bin/gcc CXX=/usr/bin/g++
Gmur answered 5/5, 2022 at 1:40 Comment(0)
D
-2

Try this:

yum install binutils
Delcine answered 11/10, 2022 at 11:20 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.