5

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.

fzd
  • 765
  • 1
  • 6
  • 19

4 Answers4

6

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
fzd
  • 765
  • 1
  • 6
  • 19
1

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.

hukeping
  • 665
  • 7
  • 12
1

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++
Kadi
  • 37
  • 6
-1

Try this:

yum install binutils
tripleee
  • 175,061
  • 34
  • 275
  • 318
hl174
  • 1