[QE-developers] QMMM Package, Compilation Error: Undefined Reference to __dom_MOD_extractdataattribute_c

Vahid Fadaei Naeini vahid.fadaei.naeini at ltu.se
Wed Mar 5 11:58:14 CET 2025


Thanks for the follow-up.
The error occurred because the function __dom_MOD_extractdataattribute_c was missing during the linking stage. This function is defined in upflib/dom.f90 and compiled into upflib/libupf.a, but it was not correctly linked to the executable. This typically happens when a library providing the required function is either missing from the linking command or is linked in the wrong order, meaning it appears before the object files that depend on it.

To resolve this, the key step is to ensure that libupf.a is properly linked after all the object files and libraries that depend on it. In the Makefile.gfortran-cmake, libupf.a should be placed at the end of the linking command to guarantee all dependencies are resolved. Additionally, cleaning previous builds (make clean) and recompiling ensures that all object files and libraries are correctly rebuilt.

After fixing the linking order, the package can be successfully compiled by running make -f Makefile.gfortran-cmake pwqmmm.x again. If any additional undefined references arise, applying the same debugging approach—identifying the missing symbols using nm and adjusting the linking order accordingly—should resolve them efficiently.

Best,
Vahid Fadaei Naeini


-----Original Message-----
From: Paolo Giannozzi <p.giannozzi at gmail.com> 
Sent: Wednesday, February 19, 2025 6:07 PM
To: Vahid Fadaei Naeini <vahid.fadaei.naeini at ltu.se>; developers at lists.quantum-espresso.org
Subject: Re: QMMM Package, Compilation Error: Undefined Reference to __dom_MOD_extractdataattribute_c

I know nothing about QMMM, but I would do the following:
- compile pw.x (no QMMM) first: does it compile and link? If so,
- look at which libraries are linked and in which order,
- modify Makefile.gfortran-cmake in such a way that all needed libraried are linked and are in the correct order FYI the missing routine is in upflib/dom.f90, compiled in upflib/libupf.a

Paolo


On 2/17/25 16:43, Vahid Fadaei Naeini wrote:
> Dear Quantum ESPRESSO Users,
> 
> I am in the process of compiling Quantum ESPRESSO with the QMMM 
> package to perform QM/MM MD simulations in combination with LAMMPS. I 
> have followed the recommended compilation procedure and successfully 
> built all the required packages using the same versions of gcc and 
> gfortran to avoid potential compatibility issues. However, in the 
> final stage of the compilation, when I execute the following command to generate pwqmmm.x:
> 
> *make -f Makefile.gfortran-cmake pwqmmm.x*
> 
> I encounter the following error:
> 
> /usr/bin/ld: /home/vahid/qe/Modules/libqemod.a(read_mol.o): in 
> function
> `read_mol_mass':
> 
> /home/vahid/qe/Modules/read_mol.f90:284: undefined reference to 
> `__dom_MOD_extractdataattribute_c'
> 
> /usr/bin/ld: /home/vahid/qe/Modules/libqemod.a(read_mol.o): in 
> function
> `read_mol_lj':
> 
> /home/vahid/qe/Modules/read_mol.f90:527: undefined reference to 
> `__dom_MOD_extractdataattribute_c'
> 
> /usr/bin/ld: /home/vahid/qe/Modules/read_mol.f90:486: undefined 
> reference to `__dom_MOD_extractdataattribute_c'
> 
> /usr/bin/ld: warning: creating DT_TEXTREL in a PIE
> 
> collect2: error: ld returned 1 exit status
> 
> make: *** [Makefile.gfortran-cmake:62: pwqmmm.x] Error 1
> 
> It appears that there are undefined references to 
> __dom_MOD_extractdataattribute_c in read_mol.f90. I have ensured that 
> all dependencies are correctly compiled and linked. I would greatly 
> appreciate any insights or recommendations to resolve this issue. Has 
> anyone encountered a similar problem when compiling the QMMM package?
> Any guidance on resolving the undefined references would be very helpful.
> 
> Best regards,
> 
> Vahid Fadaei Naeini
> 
> Researcher in Aplied Physics, Luleå University of Technology
> 
> 📧vahid.fadaei.naeini at ltu.se <mailto:mailtovahid.fadaei.naeini at ltu.se>
> 
> c/o: Vahid Fadaei Naeini, E188, 971 87 LULEÅ
> 



More information about the developers mailing list