Cabal install error /usr/bin/ld: --hash-size=31: unknown option - ld

When trying to install any package on my computer using a command like
cabal install http-conduit
the installation aborts with the following error:
/usr/bin/ld: --hash-size=31: unknown option
How can I resolve this?
Note: This question intentionally doesn't show research effort, because it was answered immediately in a Q&A-Style manner.

This issue occurs with the binutils-gold package and GHC 7.4. There is an old mailing list entry discussing this issue.
You might need binutils-gold for LLVM for example, but GHC 7.4 can't handle the GOLD linker correctly, because it doesn't understand the --hash-size option.
As noted on the mailing list post, the solution to this is to remove binutils-gold, e.g. on Ubuntu use:
sudo apt-get remove binutils-gold
This will re-symlink /usr/bin/ld to a non-GOLD linker version. After that, repeat the cabal install command.

Related

stack-protector enabled but compiler support broken while installing VirtualBox Guest Additions with devtoolset-8

Note: This problem, which I have already solved, is a very different problem from every other similar question on Stack Overflow. I have posted this question and answer in the hopes that it will help someone else experiencing the same issue (or so that, when I have this problem again in 3 years, I'll find this answer).
I am running VirtualBox 6.1.26 on macOS Catalina 10.15.7. I am emulating centOS 7:
$ uname -r
3.10.0-1160.36.2.el7.x86_64
I "inserted" the VirtualBox Guest Additions CD and followed the auto-run prompts to install the Guest Additions. Part way through, it aborted, saying:
This system is currently not set up to build kernel modules.
Please install the gcc make perl packages from your distribution.
Note that I have gcc, make, perl, kernel-devel, and kernel-headers all installed. It also prompted me to check the file /var/log/vboxadd-setup.log for more details. The contents of that log were interesting:
Building the main Guest Additions 6.1.26 module for kernel 3.10.0-1160.36.2.el7.x86_64.
Error building the module. Build output follows.
make V=1 CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL= -C /lib/modules/3.10.0-1160.36.2.el7.x86_64/build M=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 -j4 modules
arch/x86/Makefile:96: stack-protector enabled but compiler support broken
arch/x86/Makefile:166: *** CONFIG_RETPOLINE=y, but not supported by the compiler. Compiler update recommended.. Stop.
make: *** [vboxguest] Error 2
modprobe vboxguest failed
Extensive searching for these errors yields multiple forum posts and Stack Overflow questions whose replies and accepted answers reveal either that I'm missing one of those installed packages (I'm not) or that my GCC version is less than 7.3 (when support for CONFIG_RETPOLINE=y was added). However:
$ gcc --version
gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
This is > 7.3, so it does support this feature. I should note that I installed GCC using the Yum devtoolset packages in order to use this newer compiler:
$ sudo yum list installed|grep devtoolset
...
devtoolset-8-gcc.x86_64 8.3.1-3.2-el7 #centos-sclo-rh
devtoolset-8-gcc-c++.x86_64 8.3.1-3.2-el7 #centos-sclo-rh
devtoolset-8-gcc-gdb-plugin.x86_64 8.3.1-3.2-el7 #centos-sclo-rh
...
devtoolset-8-make.x86_64 1:4.2.1-4.el7 #centos-sclo-rh
...
And I do not have any other GCC versions installed:
$ sudo yum list installed|grep gcc
devtoolset-8-gcc.x86_64 8.3.1-3.2-el7 #centos-sclo-rh
devtoolset-8-gcc-c++.x86_64 8.3.1-3.2-el7 #centos-sclo-rh
devtoolset-8-gcc-gdb-plugin.x86_64 8.3.1-3.2-el7 #centos-sclo-rh
libgcc.x86_64 4.8.5-44.el7 #anaconda
And I have this in ~/.bashrc to enable devtoolset upon login:
...
source scl_source enable devtoolset-8
...
What am I doing wrong?
It turned out the problem wasn't that I was using the wrong GCC version (not possible) or that I was missing any installed packages (I wasn't). Instead, it was a consequence of how the VirtualBox Guest Additions "auto-run" works. Something about the way it runs results in a "fresh" environment without devtoolset-8 properly sourced. As a result, it cannot find the installed GCC 8.3.
The solution was simple: When the auto-run prompt appeared, I dismissed it and did not run auto-run. Instead, I opened a fresh Terminal window and changed directories to /run/media/[username]/VBox_GAs_6.1.26 (YMMV on the exact location of the mounted disk), then ran this command:
$ sudo ./VBoxLinuxAdditions.run
That command completed successfully, the kernel module compiled, the Guest Additions installed, and they are working properly now.

Net::SSLeay::Handle compiling error in Ubuntu 16.04

I've a problem to install the aforementioned module via cpanm in my multi-threading version of Perl (not the original one).
I've Ubuntu 16.04.
When trying to compile and test this module it gives me the following error:
/usr/bin/ld: impossible to find -lz
collect2: error: ld returned 1 exit status
Makefile:494: instructions set for target "blib/arch/auto/Net/SSLeay/SSLeay.so" fail
make: *** [blib/arch/auto/Net/SSLeay/SSLeay.so] Error 1
-> FAIL Installing Net::SSLeay::Handle failed. See /home/my_name/.cpanm/work/1548275319.13675/build.log for details. Retry with --force to force install it.
openssl,ssllib-dev-perl,libnet-ssleay-perl, libcrypt-ssleay-perl already installed via apt-get.
I've also tried to compile manually this module, without success. I forced the installation too...no way.
The error seems linked with something missing in /usr/bin/ld: (impossible to find -lz collect2).
Is there anyone who can help me with this?
Cpanm has always worked pretty well. Up to now i've been able to get all my modules installed and well functioning, apart from Net::SSLeay::Handle.
Thanks in advace for your help
Ok, i solved by installing this packages (Ubuntu 16.04LTS):
-openssl
-libssl-dev
-libnet-ssleay-perl
-libcrypt-ssleay-perl
-zlib1g-dev as suggested above
Once you're done doing that, remember to avoid testing the module when gcc will be finishing compiling it, because in most cases it fails.
So the best incantation in doing this should be as follows:
-cpanm install -v --notest Net::SSLeay::Handle
Many thanks again to all Perl mates writing in this forum.
You saved the day
first log in cpan
sudo cpan
force intalling the module should work
force install Net::SSLeay::Handle
This should also install missing modules or notice it

Building emacs 24.1.50

I've just updated to Kubuntu 12.04. Everything works fine except for the latest custom-build emacs. It says now:
emacs: symbol lookup error: emacs: undefined symbol: gtk_window_set_has_resize_grip
So I've decided to re-build emacs. For that I've git pull the latest snapshot, and have done everything as I usually do, but now I get an error during compilation:
In file included from /home/boris/its/blds/emacs/lib-src/emacsclient.c:76:0:
../lib/getopt.h:196:8: error: redefinition of ‘struct option’
/usr/include/getopt.h:106:8: note: originally defined here
../lib/getopt.h:245:12: error: conflicting types for ‘getopt_long’
/usr/include/getopt.h:175:12: note: previous declaration of ‘getopt_long’ was here
../lib/getopt.h:249:12: error: conflicting types for ‘getopt_long_only’
/usr/include/getopt.h:179:12: note: previous declaration of ‘getopt_long_only’ was here
make[1]: *** [emacsclient] Error 1
make[1]: Leaving directory `/home/boris/its/blds/emacs/lib-src'
make: *** [lib-src] Error 2
Google search reveals almost nothing on these errors.
Edit:
The following solves it (thanks to JSON):
git pull
./autogen.sh
./configure --prefix=/home/boris/its/soft/Emacs_24.1.50
make bootstrap
make install
The simplest way is to use PPA: emacs-snapshot.
sudo add-apt-repository ppa:cassou/emacs
sudo apt-get update
sudo apt-get install emacs-snapshot
I had these problems updating to Ubuntu 12.04, and got past it by going back to the instructions from INSTALL.BZR for first time checkout - it seems the configure file needs to be regenerated due to changes in libc in the new version of Ubuntu.
This is what I do to build emacs after a git pull (my script to do it nightly)
make distclean && autoreconf -i -I m4 && ./configure && make && sudo make install
i had the same problem than the op, and i just removed emacs from the system, and compiled from scratch.
and no, i didn't have to add a ppa, and every time i see an answer like that getting all the votes, it makes me wonder about stackexchange in general , it just misinforms and misleads others who may have the same problem.
and no, i said it once and i'll say it again, Just download the latest emacs from fsf.
let me add that getopt.h is part of libc6-dev (as json said). and libc6-dev is part of the required group like libjpeg libncurses libpng libtiff xlibs etc. remove it once and reinstall. the problem is with the configuration options path which need to be specified this time around in the prefix of emacs24 at the time of configuration. but neither autogen nor bootstrap are necessary, but just make and make install.
make maintainer-clean
./autogen.sh
./configure
make
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10108#8
I had the same issue as you but for the 24.5 tag. The problem was I didn't rerun autogen.sh to create a new configure script. I assumed that any untracked file would be listed by git status, though all the configuration output from autogen.sh is ignored in .gitignore.

Trying to install PostStat, a library to add statistics function into Postgres

I am trying to install Poststat on debian squeeze.
http://poststat.projects.postgresql.org
This project looks not so old (2008), but I am having some difficulties to install it. Although it seems to be a really interesting project, google is empty. I'll try here to sum up what I did (postgres 8.4 is installed) :
apt-get install fort77 postgresql-server-dev-8.4 libblas-dev liblapack-dev gfortran
First, as it is said on the official website, unpack the tar.gz and go in the directory f77stat and 'make'.
Then if you have libpq-dev installed, on debian squeeze it install also its owns pg_config in /usr/bin/ wich report false infos. (see http://postgresql.1045698.n5.nabble.com/Bug-report-Wrong-version-in-pg-config-td2123792.html)
One solution :
mv /usr/bin/pg_config pg_config_bak
ln -s /usr/lib/postgresql/8.4/bin/pg_config pg_config
This is important because the makefile of Poststat is retrieving some info with pg_config.
Then in the main Makefile there is the line :
-lblas -llapack -lg2c
Install those package for blas and lapack :
apt-get install libatlas-base-dev libatlas-dev libatlas-doc libatlas3gf-base
Now my problem is about g2c. According to google, g2c is obsolete so I edited the Makefile and replace -lg2c with -lgfortrant
Last step :
compile and import the new statitics functions in my database.
make && sudo make install
psql -f poststat.sql <database>
Sadly,
psql:poststat.sql:18: ERROR: unable to load the library
« /usr/lib/postgresql/8.4/lib/poststat.so » : /usr/lib/postgresql/8.4/lib/poststat.so:
undefined symbol: s_stop
Any thought ? fortran is not my world, and packages seem to have change a lot in debian about fortran. My switch from -lg2c to -lgfortrant is probably wrong. In fact removing this include does at the end produce the same error.
libg2c belongs to the g77 (http://stackoverflow.com/questions/2406581/what-is-libg2c-library), which is obsolete and unsupported for many years. Switching to a more current compiler involves more than just replacing this library. You need to replace the compiler also, e.g., gfortran. You might need to change the default compiler options of gfortran to be able to compile FORTRAN 77 code. I use: -O2 -ffixed-form -ffixed-line-length-none. If you use gfortran as the linker you won't need to explicitly include the fortran run-time library.
change -lg2c by -lf2c
Add to poststat.c , at the end
int MAIN__(){
return (0);
}

Yum won't update because of newer libstdc++ library. How do I fix this?

Whenever I try to update my system via "sudo yum update", I get this error:
Transaction Check Error:
package libstdc++-4.3.2-7.i386 (which is newer than libstdc++-4.1.2-51.el5.x86_64) is already installed
I'm not sure how I got in this state, but I'm pretty sure that whatever I've done has been through yum.
Here's what "yum list" gives me for that library:
libstdc++.x86_64 4.1.2-50.el5 installed
libstdc++.i386 4.3.2-7 installed
libstdc++-devel.x86_64 4.1.2-50.el5 installed
Notice how the i386 version is different than the .x86_64 version. That's really strange.
I'm running CentOS 5.6 64 bit.
What should I do?
You can use the lazy man's method. For now use --skip-broken so other stuff will update. And eventually your repo version of libstdc++ will catchup to what's on your box.