[nobin@CentOS9 tc-dump]$ CGO_ENABLED=1 go build
# github.com/Asphaltt/tc-dump
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -lresolv
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
OS specs:
[nobin@CentOS9 tc-dump]$ uname -a
Linux CentOS9 4.18.0-193.28.1.el8_2.x86_64 #1 SMP Thu Oct 22 00:20:22 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
[nobin@CentOS9 tc-dump]$ cat /etc/os-release
NAME="CentOS Linux"
VERSION="8 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="8"
I’m trying to compile a code. On my host ubuntu machine it compiles correctly. But one CentOS machine. It throws the following error, when invoked with CGO_ENABLED=1 go build
After trying to install the required packages I get these errors:
Updated:
[nobin@CentOS9 tc-dump]$ sudo yum install glibc-static
CentOS-8 - AppStream 6.3 kB/s | 7.9 kB 00:01
Errors during downloading metadata for repository 'AppStream':
- Status code: 404 for http://mirror.centos.org/centos/8/AppStream/x86_64/os/repodata/repomd.xml (IP: 50.2.190.74)
Error: Failed to download metadata for repo 'AppStream': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
CentOS-8 - Base 5.5 kB/s | 7.9 kB 00:01
Errors during downloading metadata for repository 'BaseOS':
- Status code: 404 for http://mirror.centos.org/centos/8/BaseOS/x86_64/os/repodata/repomd.xml (IP: 69.167.138.255)
Error: Failed to download metadata for repo 'BaseOS': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
Ignoring repositories: AppStream, BaseOS
Last metadata expiration check: 0:28:42 ago on বৃহস্পতিবার 04 এপ্রিল 2024 04:52:13 পূর্বাহ্ণ UTC.
No match for argument: glibc-static
Error: Unable to find a match: glibc-static
[nobin@CentOS9 tc-dump]$ sudo yum install libpthread-stubs
CentOS-8 - AppStream 5.1 kB/s | 7.9 kB 00:01
Errors during downloading metadata for repository 'AppStream':
- Status code: 404 for http://mirror.centos.org/centos/8/AppStream/x86_64/os/repodata/repomd.xml (IP: 104.206.99.122)
Error: Failed to download metadata for repo 'AppStream': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
CentOS-8 - Base 7.0 kB/s | 7.9 kB 00:01
Errors during downloading metadata for repository 'BaseOS':
- Status code: 404 for http://mirror.centos.org/centos/8/BaseOS/x86_64/os/repodata/repomd.xml (IP: 192.240.166.165)
Error: Failed to download metadata for repo 'BaseOS': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
Ignoring repositories: AppStream, BaseOS
Last metadata expiration check: 0:29:39 ago on বৃহস্পতিবার 04 এপ্রিল 2024 04:52:13 পূর্বাহ্ণ UTC.
No match for argument: libpthread-stubs
Error: Unable to find a match: libpthread-stubs
2
Answers
I solved it. I had to enable the PowerTools.
I also did edits on
enabled=0
instead of 1your linker is not able to find these libraries. Try installing these packages, it should solve the issue:
I am not very sure if these are the actual packages, but try related package if not, I dont have permission to comment yet, so comment on my answer before downvoting.