/usr/bin/ld error when using pgc++ 18.3

I am trying to compile a very simple “hello world” cpp program using pgc++ version 18.3.

The system I am using has an old version of /usr/bin/ld (see below):

$ ld --version
GNU ld version 20100205
Copyright 2009 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.

When I try to compile the c++ program I am getting the following error:

$ pgc++ -O3 mytest.cpp -o mytest
/usr/bin/ld: cannot find -latomic

Have anyone seen this before.
In this system I am not authorized to update the ld program.


Hi efblack2,

I don’t think this is a problem with ld but rather a misconfiguration of the compilers.

Starting with PGI 18.1 on systems with GNU 4.9 or later, pgc++ will implicitly link with the C++11 libatomic library. So my guess is that the system that was used to install the compilers had GNU 4.9 or later. Prior GNU versions did not ship this library. The configuration information is stored in the “$PGI/linuxx86-64/18.3/bin/localrc” file.

Can you please post the output from the command “pgc++ -dryrun x.o” as well as the contents of “localrc”?

If you are using a common PGI installation across several different systems, you should do a “network” install. In this case, upon first use of the compilers, a “localrc.” file is created with the configuration information for that system. The caveat being that the PGI “bin” directory needs to be writable by users or the network admin needs to run a compilation on each system to create the localrc files.



Thank for your answer.

The output from the command " pgc++ -dryrun x.o" is:
$ pgc++ -dryrun x.o
Reading rcfile /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/bin/.pgc++rc
Reading rcfile /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/bin/nativerc
Reading rcfile /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/bin/fnativerc
Reading rcfile /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/bin/ccrc
Reading rcfile /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/bin/cpprc
Reading rcfile /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/bin/cppcurc
Reading rcfile /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/bin/x86rc
Reading rcfile /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/bin/x8664rc
Reading rcfile /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/bin/lin86rc
Reading rcfile /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/bin/lin8664rc
Reading rcfile /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/bin/iparc
Reading rcfile /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/bin/acc1rc
Reading rcfile /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/bin/acclin8664rc
Skipping accxrc (not found)
Reading rcfile /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/bin/c++rc
Reading rcfile /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/bin/localrc
Skipping localrc.golubh4 (not found)
Skipping siterc (not found)
Skipping siterc.golubh4 (not found)
Skipping .mypgirc (not found)
Skipping .mypgcpprc (not found)
Skipping .mypgx86rc (not found)
Skipping $MYLOCALRC (not found)
Export PGI=/scratch/users/efblack2/pgi_18_3

/usr/bin/ld /usr/lib64/crt1.o /usr/lib64/crti.o /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/lib/trace_init.o /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtbegin.o /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/lib/initmp.o --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/lib/pgi.ld -L/scratch/users/efblack2/pgi_18_3/linux86-64/18.3/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7 x.o -rpath /scratch/users/efblack2/pgi_18_3/linux86-64/18.3/lib -rpath /usr/lib/gcc/x86_64-redhat-linux/4.4.7/…/…/…/…/lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7/…/…/…/…/lib64 -latomic -lpgatm -lstdc++ -lpgmp -lnuma -lpthread --start-group -lpgm -lnspgc -lpgc --end-group -lm -lgcc -lc -lgcc -lgcc_s /usr/lib/gcc/x86_64-redhat-linux/4.4.7/crtend.o /usr/lib64/crtn.o

The content of localr is:

set LFC=-lgfortran;
set LDSO=/lib64/ld-linux-x86-64.so.2;
set GCCDIR=/usr/lib/gcc/x86_64-redhat-linux/4.4.7;
set G77DIR=/usr/lib/gcc/x86_64-redhat-linux/4.4.7/;
set OEM_INFO=64-bit target on x86-64 Linux $INFOTPVAL;
set GNUATOMIC=-latomic;
set GCCINC= /usr/local/gcc/6.2.0/include /usr/local/torque-releases/torque-6.1.2-el6/include /usr/local/include /usr/lib/gcc/x86_64-redhat-linux/4.4.7/include /usr/include;
set GPPDIR= /usr/local/gcc/6.2.0/include /usr/include/c++/4.4.7 /usr/include/c++/4.4.7/x86_64-redhat-linux /usr/include/c++/4.4.7/backward /usr/local/include /usr/lib/gcc/x86_64-redhat-linux/4.4.7/include /usr/include;
set NUMALIBNAME=-lnuma ;
set EXTENSION=extension=;
set COMPGCCINCDIR=include-gcc44;
set LC=$if(-Bstatic,-lgcc -lgcc_eh -lc -lgcc -lgcc_eh -lc, -lgcc -lc -lgcc -lgcc_s);

GLIBC version 2.12

GCC version 4.4.7

set GCCVERSION=40407;

makelocalrc executed by


Thanks again.

It looks like the localrc has the system correctly configured for GNU 4.4.7 but there must also be a GNU 6.2 installation (as seen in the GPPDIR and GCCINC variables).

Did you or someone else manually edit the localrc file?

I ask because the script that creates the localrc file, makelocalrc, greps the verbose output from a g++ compilation to determine which include directories to add. Also, it tests if g++ successfully links with “-latomic” before setting the “GNUATOMIC” variable. In other words, the GNU version used when creating the localrc file successfully linked with -latomic.

If you didn’t manually edit localrc, I’ll investigate why having multiple GNU installs would cause the makelocalrc script to create this hybrid localrc file.

To fix your immediate issue, edit your localrc file to remove “-latomic”:


The gcc 6.2 include directories might cause some issues as well, but I’m not sure. If so, then you may want to remove these as well.

Alternatively, you can try rerunning the makelocalrc script from your current environment or move to a network install so that each system has it’s own localrc configuration.

A third option is to run the script “addlocalrc”. This script attempts to find all GNU instalations and then create a localrc file for each. You would then use the environment variable “PGI_LOCALRC” to set which localrc file to use.

Hope this helps,

Thanks once again for your attention.

I did not manually edit the localrc file before. It is as it was created after installing the pgi compiler.

Removing -latomic from the GNUATOMIC variable make the magic. It is working now.