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

Fails to find Libxc #3761

Closed
1 of 10 tasks
jinzx10 opened this issue Mar 21, 2024 · 8 comments · Fixed by #3771
Closed
1 of 10 tasks

Fails to find Libxc #3761

jinzx10 opened this issue Mar 21, 2024 · 8 comments · Fixed by #3771
Assignees

Comments

@jinzx10
Copy link
Collaborator

jinzx10 commented Mar 21, 2024

Details

The following error [Could NOT find Libxc (missing: Libxc_INCLUDE_DIRS] appears since #3623
image

I'm using Ubuntu 22.04 on WSL2. The libxc package (libxc-dev) was installed via apt. The shared object and header are located at

/usr/lib/x86_64-linux-gnu/libxc.so
/usr/include/xc.h

Compilation with libxc has no issue prior to #3623 . Can anyone give some advice?

Have you read FAQ on the online manual http://abacus.deepmodeling.com/en/latest/community/faq.html

  • Yes, I have read the FAQ part on online manual.

Task list for Issue attackers (only for developers)

  • Understand the problem or question described by the user.
  • Check if the issue is a known problem or has been addressed in the documentation.
  • Test the issue or problem on a similar system or environment, if possible.
  • Identify the root cause or provide clarification on the user's question.
  • Provide a step-by-step guide, including any necessary resources, to resolve the issue or answer the question.
  • If the issue is related to documentation, update the documentation to prevent future confusion (optional).
  • If the issue is related to code, consider implementing a fix or improvement (optional).
  • Review and incorporate any relevant feedback from users or developers.
  • Ensure the user's issue is resolved or their question is answered and close the ticket.
@WHUweiqingzhou
Copy link
Collaborator

@caic99 could you have a look?

@caic99
Copy link
Member

caic99 commented Mar 22, 2024

@caic99 could you have a look?

@yizeyi18 Could you please take a look? Thanks!

@yizeyi18
Copy link

Hi zx:
In /usr/lib/x86_64-linux-gnu/pkgconfig, there would be a file libxc.pc, and have contents like below:

prefix=/opt/libxc-6.2.2
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: libxc

Description: Library of exchange and correlation functionals to be used in DFT codes
Requires:
Version: 6.2.2
Libs: -L${libdir} -lxc
Cflags: -I${includedir}

May you show what is in your libxc.pc?

Also, after a configure failure, a CMakeCache.txt would in your build directory. May you show what does grep Libxc CMakeCache.txt output in your build directory?
It should contain lines like that:

Libxc_CFLAGS:INTERNAL=-I/opt/libxc-6.2.2/include
Libxc_CFLAGS_I:INTERNAL=
Libxc_CFLAGS_OTHER:INTERNAL=
Libxc_FOUND:INTERNAL=1
Libxc_INCLUDEDIR:INTERNAL=/opt/libxc-6.2.2/include
Libxc_INCLUDE_DIRS:INTERNAL=/opt/libxc-6.2.2/include
Libxc_LDFLAGS:INTERNAL=-L/opt/libxc-6.2.2/lib;-lxc
Libxc_LDFLAGS_OTHER:INTERNAL=
Libxc_LIBDIR:INTERNAL=/opt/libxc-6.2.2/lib
Libxc_LIBRARIES:INTERNAL=xc
Libxc_LIBRARY_DIRS:INTERNAL=/opt/libxc-6.2.2/lib
Libxc_LIBS:INTERNAL=

@jinzx10
Copy link
Collaborator Author

jinzx10 commented Mar 22, 2024

Hi @yizeyi18 , here's my libxc.pc:

prefix=/usr
exec_prefix=/usr
libdir=/usr/lib/x86_64-linux-gnu
includedir=/usr/include

Name: libxc
Description: Library of exchange and correlation functionals to be used in DFT codes
Requires:
Version: 5.1.7
Libs: -L${libdir} -lxc
Cflags: -I${includedir}

and here's the output of grep 'Libxc' CMakeCache.txt:

pkgcfg_lib_Libxc_xc:FILEPATH=/usr/lib/x86_64-linux-gnu/libxc.so
Libxc_CFLAGS:INTERNAL=
Libxc_CFLAGS_I:INTERNAL=
Libxc_CFLAGS_OTHER:INTERNAL=
Libxc_FOUND:INTERNAL=1
Libxc_INCLUDEDIR:INTERNAL=/usr/include
Libxc_INCLUDE_DIRS:INTERNAL=
Libxc_LDFLAGS:INTERNAL=-L/usr/lib/x86_64-linux-gnu;-lxc
Libxc_LDFLAGS_OTHER:INTERNAL=
Libxc_LIBDIR:INTERNAL=/usr/lib/x86_64-linux-gnu
Libxc_LIBRARIES:INTERNAL=xc
Libxc_LIBRARY_DIRS:INTERNAL=/usr/lib/x86_64-linux-gnu
Libxc_LIBS:INTERNAL=
Libxc_LIBS_L:INTERNAL=
Libxc_LIBS_OTHER:INTERNAL=
Libxc_LIBS_PATHS:INTERNAL=
Libxc_MODULE_NAME:INTERNAL=libxc
Libxc_PREFIX:INTERNAL=/usr
Libxc_STATIC_CFLAGS:INTERNAL=
Libxc_STATIC_CFLAGS_I:INTERNAL=
Libxc_STATIC_CFLAGS_OTHER:INTERNAL=
Libxc_STATIC_INCLUDE_DIRS:INTERNAL=
Libxc_STATIC_LDFLAGS:INTERNAL=-L/usr/lib/x86_64-linux-gnu;-lxc
Libxc_STATIC_LDFLAGS_OTHER:INTERNAL=
Libxc_STATIC_LIBDIR:INTERNAL=
Libxc_STATIC_LIBRARIES:INTERNAL=xc
Libxc_STATIC_LIBRARY_DIRS:INTERNAL=/usr/lib/x86_64-linux-gnu
Libxc_STATIC_LIBS:INTERNAL=
Libxc_STATIC_LIBS_L:INTERNAL=
Libxc_STATIC_LIBS_OTHER:INTERNAL=
Libxc_STATIC_LIBS_PATHS:INTERNAL=
Libxc_VERSION:INTERNAL=5.1.7
Libxc_libxc_INCLUDEDIR:INTERNAL=
Libxc_libxc_LIBDIR:INTERNAL=
Libxc_libxc_PREFIX:INTERNAL=
Libxc_libxc_VERSION:INTERNAL=
__pkg_config_checked_Libxc:INTERNAL=1
//ADVANCED property for variable: pkgcfg_lib_Libxc_xc
pkgcfg_lib_Libxc_xc-ADVANCED:INTERNAL=1

@yizeyi18
Copy link

and here's the output of grep 'Libxc' CMakeCache.txt:

Libxc_CFLAGS:INTERNAL=
Libxc_CFLAGS_I:INTERNAL=
Libxc_CFLAGS_OTHER:INTERNAL=
Libxc_FOUND:INTERNAL=1
Libxc_INCLUDEDIR:INTERNAL=/usr/include
Libxc_INCLUDE_DIRS:INTERNAL=

Libxc_FOUND, but no Libxc_INCLUDE_DIRS, nor Libxc_CFLAGS...? Quite strange.
As a quick fix, you could try this patch: quick.patch
It may take some time to detect what's wrong here.

@jinzx10
Copy link
Collaborator Author

jinzx10 commented Mar 22, 2024

and here's the output of grep 'Libxc' CMakeCache.txt:

Libxc_CFLAGS:INTERNAL=
Libxc_CFLAGS_I:INTERNAL=
Libxc_CFLAGS_OTHER:INTERNAL=
Libxc_FOUND:INTERNAL=1
Libxc_INCLUDEDIR:INTERNAL=/usr/include
Libxc_INCLUDE_DIRS:INTERNAL=

Libxc_FOUND, but no Libxc_INCLUDE_DIRS, nor Libxc_CFLAGS...? Quite strange. As a quick fix, you could try this patch: quick.patch It may take some time to detect what's wrong here.

The patch works! Thank you very much :)

@yizeyi18
Copy link

yizeyi18 commented Mar 22, 2024

Hi zx:
I propose the problem comes like that: the output var Libxc_INCLUDE_DIRS is empty because pkg-config filters /usr/include out, as pkg_search_module relies. This do not affect compile process but crashes cmake's find_package_handle_standard_args.
According to this, I made the PR above, runs on my pc. May you take a look?

Debug output of pkg-config

$ pkg-config --debug --cflags libxc
Error printing enabled by default due to use of output options besides --exists, --atleast/exact/max-version or --list-all. Value of --silence-errors: 0
Error printing enabled
Adding virtual 'pkg-config' package to list of known packages
Looking for package 'libxc'
Looking for package 'libxc-uninstalled'
Reading 'libxc' from file '/usr/lib/x86_64-linux-gnu/pkgconfig/libxc.pc'
Parsing package file '/usr/lib/x86_64-linux-gnu/pkgconfig/libxc.pc'
  line>prefix=/usr
 Variable declaration, 'prefix' has value '/usr'
  line>exec_prefix=/usr
 Variable declaration, 'exec_prefix' has value '/usr'
  line>libdir=/usr/lib/x86_64-linux-gnu
 Variable declaration, 'libdir' has value '/usr/lib/x86_64-linux-gnu'
  line>includedir=/usr/include
 Variable declaration, 'includedir' has value '/usr/include'
  line>
  line>Name: libxc
  line>Description: Library of exchange and correlation functionals to be used in DFT codes
  line>Requires:
  line>Version: 5.1.7
  line>Libs: -L${libdir} -lxc
  line>Cflags: -I${includedir}
Path position of 'libxc' is 5
Adding 'libxc' to list of known packages
Package libxc has -I/usr/include in Cflags
Removing -I/usr/include from cflags for libxc
Package libxc has -L /usr/lib/x86_64-linux-gnu in Libs
Removing -L /usr/lib/x86_64-linux-gnu from libs for libxc
 post-recurse: libxc
adding CFLAGS_OTHER string ""
 post-recurse: libxc
 original: libxc
   sorted: libxc
adding CFLAGS_I string ""
returning flags string ""

@jinzx10 @caic99

@jinzx10
Copy link
Collaborator Author

jinzx10 commented Mar 22, 2024

Hi @yizeyi18 ,
Thanks for the explanation! I just checked out #3771 and it indeed solves my issue. I think this issue can be closed alongside the merge of #3771 . @caic99

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

Successfully merging a pull request may close this issue.

4 participants