Error when compiling with gcc 'undefined reference to `libint2_static_cleanup'
Closed this issue · 2 comments
When compiling a project derived from the hartree-fock++.cc, I get error as follows.
I used version 2.7.1 of libint and gcc version 8.3.0 on Debian.
gcc -O2 -o sys-integrals sysmaker.cc -I/usr/local/libint/2.8.0/include/ -I/usr/local/include/eigen3/ -I/lib/boost/include -lm -lstdc++
/usr/bin/ld: /tmp/cc5Cax8u.o: in function 'std::unique_ptr<libint2::detail::__initializer, std::default_delete<libint2::detail::__initializer>::~unique_ptr()':
sysmaker.cc:(.text._ZNSt10unique_ptrIN7libint26detail13__initializerESt14default_deleteIS2_EED2Ev[_ZNSt10unique_ptrIN7libint26detail13__initializerESt14default_deleteIS2_EED5Ev]+0xa): undefined reference to 'libint2_static_cleanup'
/usr/bin/ld: /tmp/cc5Cax8u.o: in function 'libint2::Engine::~Engine()':
sysmaker.cc:(.text._ZN7libint26EngineD2Ev[_ZN7libint26EngineD5Ev]+0xf): undefined reference to 'libint2_cleanup_default'
/usr/bin/ld: /tmp/cc5Cax8u.o: in function 'libint2::Engine::_initialize()':
sysmaker.cc:(.text._ZN7libint26Engine11_initializeEv[_ZN7libint26Engine11_initializeEv]+0x30d): undefined reference to 'libint2_need_memory_default'
/usr/bin/ld: sysmaker.cc:(.text._ZN7libint26Engine11_initializeEv[_ZN7libint26Engine11_initializeEv]+0x325): undefined reference to 'libint2_init_default'
/usr/bin/ld: sysmaker.cc:(.text._ZN7libint26Engine11_initializeEv[_ZN7libint26Engine11_initializeEv]+0x32c): undefined reference to 'libint2_build_default'
/usr/bin/ld: sysmaker.cc:(.text._ZN7libint26Engine11_initializeEv[_ZN7libint26Engine11_initializeEv]+0x387): undefined reference to 'libint2_need_memory_default'
[...]
/usr/bin/ld: sysmaker.cc:(.text._ZN7libint26Engine11_initializeEv[_ZN7libint26Engine11_initializeEv]+0x226c): undefined reference to 'libint2_cleanup_default'
/usr/bin/ld: sysmaker.cc:(.text._ZN7libint26Engine11_initializeEv[_ZN7libint26Engine11_initializeEv]+0x2280): undefined reference to 'libint2_cleanup_default'
/usr/bin/ld: sysmaker.cc:(.text._ZN7libint26Engine11_initializeEv[_ZN7libint26Engine11_initializeEv]+0x2294): undefined reference to 'libint2_cleanup_default'
/usr/bin/ld: sysmaker.cc:(.text._ZN7libint26Engine11_initializeEv[_ZN7libint26Engine11_initializeEv]+0x22a8): undefined reference to 'libint2_cleanup_default'
/usr/bin/ld: /tmp/cc5Cax8u.o:sysmaker.cc:(.text._ZN7libint26Engine11_initializeEv[_ZN7libint26Engine11_initializeEv]+0x22bc): more undefined references to 'libint2_cleanup_default' follow
/usr/bin/ld: /tmp/cc5Cax8u.o: in function 'main':
sysmaker.cc:(.text.startup+0x2aed): undefined reference to 'libint2_static_cleanup'
/usr/bin/ld: sysmaker.cc:(.text.startup+0x2d0b): undefined reference to 'libint2_static_init'
/usr/bin/ld: sysmaker.cc:(.text.startup+0x2d23): undefined reference to 'libint2_static_cleanup'
collect2: error: ld returned 1 exit status
I'm not at all sure that this is your problem, but depending on where you're linking to libint from (build or install tree) and the buildsys to assemble your hf++ derived project (gnu make or cmake), you may want to try adding the compile definition __COMPILING_LIBINT2=1
as described slightly more under https://github.com/loriab/libint/blob/new-cmake-2023-take2-b/INSTALL.md#detection-time-compatibility
The problem were missing statements in the gcc statement:
-L /usr/local/libint/2.8.0/lib64/ -lint2
The errors complained that gcc did only find headers without the corresponding linbrary files.
so that the compile prompt is as follows:
gcc -O2 -o sys-integrals sysmaker.cc -I/usr/local/libint/2.8.0/include/ -I/usr/local/include/eigen3/ -I/lib/boost/include -lm -lstdc++ -L /usr/local/libint/2.8.0/lib64/ -lint2