Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]collect2: error: ld returned 1 exit status #241

Open
andrewsilver1997 opened this issue Oct 5, 2024 · 6 comments
Open

[BUG]collect2: error: ld returned 1 exit status #241

andrewsilver1997 opened this issue Oct 5, 2024 · 6 comments

Comments

@andrewsilver1997
Copy link

Describe the bug
A clear and concise description of what the bug is.
I had ``make: *** [Makefile:135: enzo.exe] Error 1'' while compiling make-linux-gnu with GCCcore/11.3.0, OpenMPI/4.1.4-GCC-11.3.0, HDF5/1.12.2-gompi-2022a

when I did ``cat out.compile'', it said:
/cvmfs/hpc.rug.nl/versions/2023.01/rocky8/x86_64/amd/zen3/software/binutils/2.38-GCCcore-11.3.0/bin/ld: error: /lib: read: Is a directory
collect2: error: ld returned 1 exit status

I was running on computer cluster.
And FYI, I followed the step as #167 suggested:
add -std=legacy to MACH_FFLAGS
add -std=legacy to the MACH_F90FLAGS

Thank you for your help.

@jwise77
Copy link
Contributor

jwise77 commented Oct 8, 2024

I've seen this happen when there's an extra space at the end of the line in the machine file where you specify the library directories. The make system adds a /lib at the end of the given directory, and if there's a space, the lib/ append will be its own word. If this doesn't solve your problem, could you upload your machine file?

@andrewsilver1997
Copy link
Author

Hi,

Thank you. The compiling process moved forward a bit but stopped at Compiling uuid/uuid_time.c.
out.compile gave me the following:

/cvmfs/hpc.rug.nl/versions/2023.01/rocky8/x86_64/amd/zen3/software/binutils/2.38-GCCcore-11.3.0/bin/ld: error: /lib: read: Is a directory
collect2: error: ld returned 1 exit status

My machine file is written here:

Make.mach.linux-gnu.pdf

@jwise77
Copy link
Contributor

jwise77 commented Oct 8, 2024

You have to give the directory where HDF5 lives on your machine in the variable LOCAL_HDF5_INSTALL. The make system won't automatically find it for you. The same thing goes for grackle if you're using it. If HDF5 is loaded through a module on the HPC machine you're using, you can do something like which h5ls to see where it exists and remove the ending /bin and put that parent directory in your machine file.

@andrewsilver1997
Copy link
Author

Hi,

Thanks for the reply. But unfortunately it still didn't work after I specified HDF5 path. This is what I did:
LOCAL_HDF5_INSTALL = /cvmfs/hpc.rug.nl/versions/2023.01/rocky8/x86_64/amd/zen3/software/HDF5/1.14.3-gompi-2023b

Is there anything else I can do?

@jwise77
Copy link
Contributor

jwise77 commented Oct 9, 2024

Can you upload the original out.compile file in plain text? Also could you reupload your machine file in plain text instead of a PDF since it's easier to find any problems that way. You can use pastebin.com if it's easier for you.

@andrewsilver1997
Copy link
Author

This is my out.compile:
/cvmfs/hpc.rug.nl/versions/2023.01/rocky8/x86_64/amd/zen3/software/binutils/2.40-GCCcore-13.2.0/bin/ld: error: /lib: read: Is a directory
collect2: error: ld returned 1 exit status

This is my makefile (Make.machine.linux-gnu):
#=======================================================================

FILE: Make.mach.linux-gnu

DESCRIPTION: Makefile settings for a linux machine

AUTHOR: Rick Wagner ([email protected])

DATE: 2008-09-16 (updated 2019-09-11)

Depending on your linux distribution several packages need to be installed

to satisfy the minimum Enzo requirements (GNU compiler suite with

gfortran/gcc/g++, an MPI library for parallel runs, and HDF5 for data outputs).

Sample environments

Ubuntu/Debian (see also Make.mach.ubuntu):

$ apt-get install build-essentials gfortran libhdf5-10 libopenmpi-dev openmpi-bin

Fedora/Redhat:

$ yum install make automake gcc gcc-c++ gcc-gfortran kernel-devel openmpi openmpi-devel

Arch Linux:

$ pacman -S base-devel gcc-fortran openmpi hdf5

#=======================================================================

MACH_TEXT = Generic GNU/Linux machine file. Requires gfortran/gcc/g++, OpenMPI, and a
serial HDF5 library. Make sure to set the correct LOCAL_HDF5_INSTALL path in the
machine file (e.g., /usr for a system-wide installation or a custom path for local
installations).
MACH_VALID = 1
MACH_FILE = Make.mach.linux-gnu

#-----------------------------------------------------------------------

Install paths (local variables)

#-----------------------------------------------------------------------

LOCAL_HDF5_INSTALL = /cvmfs/hpc.rug.nl/versions/2023.01/rocky8/x86_64/amd/zen3/software/HDF5/1.14.3-gompi-2023b # mandatory
LOCAL_GRACKLE_INSTALL = /PATH/TO/GRACKLE/INSTALL # optional
LOCAL_HYPRE_INSTALL = /PATH/TO/HYPRE/INSTALL # optional

#-----------------------------------------------------------------------

Compiler settings

#-----------------------------------------------------------------------

MACH_CPP = cpp # C preprocessor command

With MPI

MACH_CC_MPI = mpicc # C compiler when using MPI
MACH_CXX_MPI = mpic++ # C++ compiler when using MPI
MACH_FC_MPI = gfortran # Fortran 77 compiler when using MPI
MACH_F90_MPI = gfortran # Fortran 90 compiler when using MPI
MACH_LD_MPI = mpic++ # Linker when using MPI

Without MPI

MACH_CC_NOMPI = gcc # C compiler when not using MPI
MACH_CXX_NOMPI = g++ # C++ compiler when not using MPI
MACH_FC_NOMPI = gfortran # Fortran 77 compiler when not using MPI
MACH_F90_NOMPI = gfortran # Fortran 90 compiler when not using MPI
MACH_LD_NOMPI = g++ # Linker when not using MPI

#-----------------------------------------------------------------------

Machine-dependent defines

#-----------------------------------------------------------------------

MACH_DEFINES = -DLINUX -DH5_USE_16_API

#-----------------------------------------------------------------------

Compiler flag settings

#-----------------------------------------------------------------------

MACH_CPPFLAGS = -P -traditional
MACH_CFLAGS =
MACH_CXXFLAGS =
MACH_FFLAGS = -fno-second-underscore -ffixed-line-length-132 -std=legacy
MACH_F90FLAGS = -fno-second-underscore -std=legacy
MACH_LDFLAGS =

#-----------------------------------------------------------------------

Optimization flags

#-----------------------------------------------------------------------

MACH_OPT_WARN = -Wall -g
MACH_OPT_DEBUG = -g
MACH_OPT_HIGH = -O2
MACH_OPT_AGGRESSIVE = -O3 -g

#-----------------------------------------------------------------------

Includes

#-----------------------------------------------------------------------

LOCAL_INCLUDES_MPI = # MPI includes
LOCAL_INCLUDES_HDF5 = -I$(LOCAL_HDF5_INSTALL)/include # HDF5 includes
LOCAL_INCLUDES_HYPRE = -I$(LOCAL_HYPRE_INSTALL)/include
LOCAL_INCLUDES_PAPI = # PAPI includes
LOCAL_INCLUDES_GRACKLE = -I$(LOCAL_GRACKLE_INSTALL)/include

MACH_INCLUDES = $(LOCAL_INCLUDES_HDF5)
MACH_INCLUDES_MPI = $(LOCAL_INCLUDES_MPI)
MACH_INCLUDES_HYPRE = $(LOCAL_INCLUDES_HYPRE)
MACH_INCLUDES_PAPI = $(LOCAL_INCLUDES_PAPI)
MACH_INCLUDES_GRACKLE = $(LOCAL_INCLUDES_GRACKLE)

#-----------------------------------------------------------------------

Libraries

#-----------------------------------------------------------------------

LOCAL_LIBS_MPI = # MPI libraries
LOCAL_LIBS_HDF5 = -L$(LOCAL_HDF5_INSTALL)/lib -lhdf5 -lz
LOCAL_LIBS_HYPRE = -L$(LOCAL_HYPRE_INSTALL)/lib -lHYPRE
LOCAL_LIBS_PAPI = # PAPI libraries
LOCAL_LIBS_MACH = -lgfortran # Machine-dependent libraries
LOCAL_LIBS_GRACKLE = -L$(LOCAL_GRACKLE_INSTALL)/lib -lgrackle

MACH_LIBS = $(LOCAL_LIBS_HDF5) $(LOCAL_LIBS_MACH)
MACH_LIBS_MPI = $(LOCAL_LIBS_MPI)
MACH_LIBS_HYPRE = $(LOCAL_LIBS_HYPRE)
MACH_LIBS_PAPI = $(LOCAL_LIBS_PAPI)
MACH_LIBS_GRACKLE = $(LOCAL_LIBS_GRACKLE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants