SECTIONS seen after other input files;

Hi, I just run the first C example from PGI Compilers & Tools
but I get the below error:

/usr/bin/ld: error: /home/john/.local/lib/pgi/linux86-64/13.1/lib/pgi.ld: SECTIONS seen after other input files; try -T/--script
/usr/bin/ld: internal error in input_sections_begin, at ../../gold/merge.h:269

Please tell me how to do it.
thanks.

Hi John,

I had another user get the same thing, see: Error when compiling example code and from what I could tell it’s a problem with linker from the “binutils-gold” package. Can you try installing the standard binutils? (Index of /gnu/binutils)

Thanks,
Mat

Thanks Mat, I will give it a try now

Sorry the problem still there even I have installed the binutils lib.

But actually, I have some confuse on the installation, since the installed lib doesn’t have any merge.h file in it.

Any ideas?

Hi John,

I not sure but I suspect that you still have the ‘gold’ ld in your PATH. What’s the output from “ld --version”?

If this is the case, then either set your PATH so the new ld is picked up or add “LD=/path/to/binutils/bin” to your link line.

  • Mat

Hi Mat,

Yes!! You are right!

I just moved out original ld (gold) from the PATH, and the error is gone.

But some new come out:

/home/john/.local/lib/binutils/bin/ld: cannot find -ldl
/home/john/.local/lib/binutils/bin/ld: cannot find -lpthread
/home/john/.local/lib/binutils/bin/ld: cannot find -lm
/home/john/.local/lib/binutils/bin/ld: cannot find -lc

any idea? Thanks

Hmm, that means the linker doesn’t know where to look for the standard system libraries. There’s probably some configuration missing, but unfortunately I don’t know what needs to be done. Maybe it’s because you have it installed in your local directory?

Instead, try adding “-L/usr/lib” to your link line. If that doesn’t work, add the verbose flag (-v) to your link command, and post the fill output. Not sure it will help, but it may give us some ideas.

  • Mat

It’s a bug in the PGI driver. PGI doesn’t have a linker, instead it invokes whatever ld the system can find in $PATH and adds command line options to it. While doing that, in contrast to gcc it doesn’t add “-L/lib/x86_64-linux-gnu” option. If the stars are aligned correctly, the first ld in $PATH is “/usr/bin/ld”, which is patched to work fine without “-L/lib/x86_64-linux-gnu”. If the stars are not in your favor, PGI will start another linker and will fail.

As of now, 7 years later, the bug is still there.