Makefile Compiling 32 bit gfortran program with on Centos 7 gives errors such as: /bin/ld: cannot find -lpthread

I downloaded the latest release of gfortran from: gcc-11.1.0.tar.xz to a VMware Centos 7 32 bit Virtual Machine.

I was able to build gfortran and run a Fortran hello world program.

When I run my company’s Makefile to build a “complex” Fortran proprietary program, I get the following errors. (Note: xyz, abc.o and rst.o are not the actual identifiers in the output.)

Making xyz
Making xyz1.Linux
Loading xyz1 ...
gfortran -w -u -g -m32 -static xyz.o abc.o rst.o ../../libs/lib1/1.a -lpthread ../../libs/lib1/1.a -lpthread -o xyz

/bin/ld: cannot find -lpthread
/bin/ld: cannot find -lpthread
/bin/ld: cannot find -lgfortran
/bin/ld: cannot find -lm
/bin/ld: cannot find -lquadmath
/bin/ld: cannot find -lm
/bin/ld: cannot find -lc

collect2: error: ld returned 1 exit status 
make: *** [PROGRAM] Error 1

I found this in the gfortran directory that I downloaded gfortran to : gcc-11.1.0-32bit/lib/libquadmath.so.0

And, I found these two symbolic links:

cd /bin;ls -laF ld
/bin/ld -> /etc/alternatives/ld*

cd /etc/alternatives;ls -laF ld 
/etc/alternatives/ld -> /usr/bin/ld.bfd*

cd ld.bfd
-bash: cd: ld.bfd: No such file or directory

Question: What do I do to compile everything with this Makefile (Fortran program)?

In order to get past a previous Makefile error: I executed the following command because the Makefile couldn’t find the csh:

sudo yum install csh

Old makefiles can be a pain in the ass. Been there done that.

You know that for Centos-7 you can install the “devtoolset-11” package that gives you this compiler in a good working shape with all dependencies? This is basically the RHEL developer toolkit, which is Red Hat’s way of providing an updated developemnt platform for their RHEL distros. I use it a lot and it’s great.

Are you sure devtoolset-XX are available in 32-bit version of RHEL/CentOS-7? My guess would be it is not. Also, gfortran coming with devtoolset-11 apparently cannot create 32-bit executables, failing to find libgfortran_nonshared.a.

Thanks everyone, I’ve gotten the Makefile to work.

Looks like duplicate thread of this one. Maybe should be merged by admins.