golang 1.17 build failure [gcc failed: exit status 1] - go

ERROR:
/var/lib/jenkins/tools/org.jenkinsci.plugins.golang.GolangInstallation/go1.17/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: /tmp/go-link-350634742/000048.o: unrecognized relocation (0x2a) in section `.text'
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
FLAGS:
GO111MODULE = on
Command:
go mod vendor is working downloading all the dependencies
go install serviceName fails with the error above
GCC VERSION:
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)

Far as I see you are trying to use CGO for your build
Try Command This Command will tell the compiler to use CGO
CGO_ENABLED=1 go build
if you have custom compiler or if GO couldn't find the binary you can specify
CGO_ENABLED=1 CXX=g++ CC=gcc go build
if it is not worked out for you can customize the path or binary name of the compiler
CXX=x86_64-w64-mingw32-g++ CC=x86_64-w64-mingw32-gcc go build -x
if this answer still didn't work out a reply we could look into it again.

Related

/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1

trying to run a golang program, but I receive the error of gcc as:
command-line-arguments
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
collect2: fatal error: ld terminated with signal 9 [Killed]
compilation terminated.
(go version is 1.13, amd64, gcc version is 7.5.0,
I used following as well and the same error exits:
export CXXFLAGS="-stdlib=libstdc++"
CC=/usr/bin/gcc CXX=/usr/bin/g++)
Thanks.
Cheers

Static linking library asan with gcc 4.8

I'm compiling my test executable in this way using gcc 4.8.3:
gcc -o test -g -L/lib64 -fsanitize=address -static-libasan
Result:
/usr/bin/ld: cannot find -lasan
collect2: error: ld returned 1 exit status
Libasan is installed and if I compile without the static option it works. How can I compile the library statically?
You need to install special package to get static GCC libraries. On Ubuntu you should do
$ sudo apt-get install libgcc-4.8-dev

How to solve: /usr/bin/ld: cannot find -lGL

I use AOSP to build Android.
I use these commands to build Android on my Ubuntu 17.04:
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
repo sync -j8
. build/envsetup.sh
lunch
make -j8
and after 30 minutes this error came, anybody knows how to fix it?
host Executable: tblgen (out/host/linux-x86/obj/EXECUTABLES/tblgen_intermediates/tblgen)
/usr/bin/ld: cannot find -lGL
collect2: ld returned 1 exit status
/usr/bin/ld: cannot find -lGL
/usr/bin/ld: cannot find -lGL
make: *** [out/host/linux-x86/obj/lib/libGLES_CM_translator.so] Error 1
make: *** Waiting for unfinished jobs....
collect2: ld returned 1 exit status
collect2: ld returned 1 exit status
It would appear that you have not completely followed the "Establishing a Build Environment" instructions completely.
I see you're trying to build Android Ice Cream Sandwich (4.0.1) on Ubuntu 17 - please note that this is not a supported build / host environment and may not function correctly.
It would appear that you have a misconfigured or missing installs of the libx11-dev and libgl1-mesa-dev libraries (or whatever their Ubuntu 17 equivalents are named).
I would recommend installing Ubuntu 14 and trying Android L or N instead.
Using these solutions will solve the problems:
for -lGL error:
sudo apt-get install libgl1-mesa-dev:i386
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
for -lX11 error:
add this line LOCAL_LDLIBS += -lX11 to the file
development/tools/emulator/opengl/host/renderer/Android.mk
More information:
http://developers-club.com/posts/209206/
http://www.mamicode.com/info-detail-232796.html
You are missing a libGL.so file. This is the OpenGL library. Ensure that you have the appropriate OpenGL library installed and it is part of the search path (see -L directives).

Golang can't set rpath (Mac)?

Hello currently I tried to set -rpath with pkg-config for golang, however I always get the following:
ld: -rpath can only be used when creating a dynamic final linked image
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Is there any way to fix it?
I tried to use LDFLAGS with -Wl,rpath and I have a pkg-config with -rpath both are failing with the same error.
I also stumbled on github on this: https://github.com/golang/go/issues/7293
Which means that it should work?

gcov final link failed

While compiling my project with gcov support I am facing the below error
Following are flags information i have while compiling
compiler flags:
CXXFLAGS="-Wno-deprecated -g -ggdb -fprofile-arcs -ftest-coverage -fPIC"
linker options:
LINK_CMD="gcc -fprofile-arcs -fPIC"
Following are version information:
gcc version:
gcc version 4.1.2 20080704 (Red Hat 4.1.2-44)
gcov version:
gcov (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44)
error:
hidden symbol `__gcov_init' in /usr/lib/gcc/x86_64-redhat-linux/4.1.2/libgcov.a(_gcov.o) is referenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
Could you please help me to get away from this problem?
I have been able to solve this problem in my own code using these steps:
Make clean (remove all of my .o and lib files).
Ensure every source file has the correct options (-fprofile-arcs -ftest-coverage).
Ensure every shared library the source files are compiled into specify -lgcov
Ensure I link the executable with -lgcov.
See also this answer and this blog post.

Resources